Skip to main content
Version: 23.8.0

PDF 生成

¥PDF generation

要打印 PDF,请使用 Page.pdf()

¥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();

默认情况下,Page.pdf() 等待字体加载。

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