puppeteer/website/versioned_docs/version-22.11.0/guides/pdf-generation.md
release-please[bot] 74d9969744
chore: release main (#12573)
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
2024-06-12 10:41:26 +00: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.