puppeteer/docs/guides/pdf-generation.md
2024-04-11 11:08:28 +02:00

465 B

PDF generation

For printing PDFs use Page.pdf().

const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://news.ycombinator.com', {
  waitUntil: 'networkidle2',
});
// Saves the PDF to hn.pdf.
await page.pdf({
  path: 'hn.pdf',
});

await browser.close();

By default, the Page.pdf() waits for fonts to be loaded.