pdf fix
This commit is contained in:
@@ -13,13 +13,15 @@ export async function renderPdf(html: string) {
|
||||
const page = await browser.newPage();
|
||||
await page.setContent(html, { waitUntil: "networkidle0" });
|
||||
|
||||
return await page.pdf({
|
||||
const pdf = await page.pdf({
|
||||
format: "A4",
|
||||
printBackground: true,
|
||||
preferCSSPageSize: true,
|
||||
});
|
||||
|
||||
// Normalize Puppeteer's Uint8Array output to a Node Buffer so Express sends a valid PDF payload.
|
||||
return Buffer.from(pdf);
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user