This commit is contained in:
2026-03-15 00:00:13 -05:00
parent 86588c6134
commit 006b14d93d

View File

@@ -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();
}
}