Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Use Puppeteer’s page.pdf() after navigating to the page. Its waitForFonts option waits for document.fonts.ready and is documented as true by default, so you can set it explicitly for clarity. The example below also checks the navigation response and closes the browser reliably.

Generate a PDF after Puppeteer loads the page

Install Puppeteer in your Node.js project if you have not already, then save this as an ES module file such as save-page.js. Replace the example URL with the page you want to capture.

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  const response = await page.goto('https://example.com', {
    waitUntil: 'networkidle2',
  });

  if (response && !response.ok()) {
    throw new Error(`Navigation failed: ${response.status()}`);
  }

  await page.pdf({
    path: 'page.pdf',
    waitForFonts: true,
    format: 'A4',
    printBackground: true,
  });
} finally {
  await browser.close();
}

Run it with node save-page.js. Puppeteer writes page.pdf to the current working directory. The documented PDFOptions API (version 25.12.0 in the documentation result) says waitForFonts defaults to true; including it explicitly makes the font behavior visible in your code.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What the font wait does

waitForFonts: true waits for the page’s document.fonts.ready promise to resolve before generating the PDF. This is the font-specific readiness condition. A navigation wait such as waitUntil: 'networkidle2' is not a substitute: it governs navigation readiness, not whether the document’s fonts are ready. Puppeteer documents these separately in its PDF generation guide and network-idle API.

#1 Best Overall
Brother DCP-L2640DW Wireless Compact Monochrome Multi-Function Printer, Copy, Scan, Duplex, Mobile Printing
  • BEST FOR SMALL BUSINESSES – Engineered for extraordinary productivity, the Brother DCP-L2640DW Monochrome (Black & White) 3-in-1 combines laser printer, scanner, copier in one compact footprint and delivers high-quality black & white prints
  • FAST PRINTER WITH EFFICIENT SCANNING – Produces documents quickly with print speeds up to 36 ppm(2) and scan speeds up to 23.6/7.9 ipm(3) (black/color). A 50-page auto document feeder(4) allows for convenient, time saving multi-page scanning and copying
  • FLEXIBLE CONNECTION OPTIONS – Easily navigate the changing demands of your business with secure multi-device connectivity via built-in dual-band wireless (2.4GHz / 5GHz) and Ethernet. Or connect locally to a single computer via USB interface
  • BROTHER MOBILE CONNECT APP – Print, scan, and manage your wireless printer anytime, from almost anywhere from your mobile device. Order Brother Genuine Supplies, track toner usage, and complete more work on-the-go(5)
  • CHOOSE BROTHER GENUINE TONER – When it’s time to replace your toner, be sure to choose Brother Genuine TN830 or TN830XL replacement toner. And with Refresh EZ Print Subscription Service, you’ll never worry about running out of toner again and you’ll enjoy savings of up to 50%(6) on Brother Genuine Toner. Get started with Refresh today with a Free Trial(1)

Smallest working pattern

If you already have a page object and do not need extra navigation handling, the essential sequence is:

await page.goto(url);
await page.pdf({ path: 'page.pdf', waitForFonts: true });

The options reference documents waitForFonts as enabled by default, so the explicit setting is optional unless you want the intent stated in your code.

Rank #2
Canon imageCLASS MF273dw - Monochrome Wireless Laser Printer, Multifunction With Scanner, Copier, Auto Document Feeder, With 1 Year Limited Warranty, 30 PPM, Black
  • Wireless 3-in-1: Print | Copy | Scan
  • Print up to 30 Pages Per Minute (BW, Letter)
  • First Print Out in Approximately 5.3 Seconds (Letter)
  • Auto 2-sided Printing
  • Uses Toner 071 / 071 High-Capacity Toner

Choose the PDF’s media, paper, and appearance

Print CSS or screen CSS

page.pdf() uses print CSS media by default. If the webpage must be rendered with its screen styles, call page.emulateMediaType('screen') before calling page.pdf(). See Puppeteer’s Page class reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Backgrounds and colors

printBackground defaults to false; set it to true when the PDF should include CSS background graphics. Puppeteer notes that print output may adjust colors by default. To request exact colors in the page’s print styles, use the CSS property -webkit-print-color-adjust, as described in the Page reference.

Rank #3
Sale
HP Laserjet MFP M140w Wireless Black & White Printer, Print, scan, Copy, Fast speeds, Easy Setup, Mobile Printing, Best-for-Small Teams
  • FROM AMERICA'S MOST TRUSTED PRINTER BRAND – Perfect for small teams printing, scanning and copying professional-quality black & white documents and reports. Perfect for 1-3 people
  • WORLD'S SMALLEST LASER IN ITS CLASS – Precision laser printing, scanning, and copying that fits anywhere
  • FAST PRINT SPEEDS – Up to 21 black-and-white pages per minute single-sided
  • WIRELESS WITH SELF-RESET – Helps you stay connected
  • EASILY COPY ID CARDS AND MORE – Copy both sides of ID cards or other small-size documents onto the same side of one sheet of paper

Paper size and layout options

The PDFOptions API documents Letter as the default paper format. You can instead specify a named format such as A4, set dimensions and margins, choose landscape orientation, select page ranges, adjust scale, and set an output path. The PDF operation’s timeout is documented as 30,000 milliseconds by default and can be configured through page default timeout settings. Consult the PDFOptions reference for the exact option names and accepted values for your installed Puppeteer version.

Handle pages that need extra readiness checks

Background pages

Puppeteer notes that waiting for fonts may require activating a page that is in the background. If font readiness appears to stall in that situation, bring the page to the foreground before generating the PDF:

Rank #4
HP LaserJet MFP M235sdw | Monochrome | Laser Printer | All-in-One | Duplex
  • FROM AMERICA'S MOST TRUSTED PRINTER BRAND – Perfect for offices printing, scanning and copying black & white brochures, business documents and presentations. Perfect for 1-5 people
  • FASTEST TWO-SIDED PRINTING IN ITS CLASS – Up to 28 black-and-white pages per minute single-sided. Quickly finish multipage print projects with the fastest in-class two-sided printing speed
  • DUAL-BAND WI-FI WITH SELF-RESET – Automatically detects and resolves connectivity issues
  • STRONG SECURITY – Built-in security features help protect your printer from potential attacks
  • PRINT FROM ANY DEVICE – Wireless printing from any mobile device, PC or tablet. Ethernet included. Works with Microsoft, Mac, AirPrint, Android, Chromebook and more.
await page.bringToFront();
await page.pdf({ path: 'page.pdf', waitForFonts: true });

Application-specific content

Some pages populate content after navigation—for example, through client-side rendering. If the PDF must wait for a particular element or application state, add a page-specific condition rather than treating network idleness as proof that the content is ready. page.waitForFunction() can wait until a synchronous or asynchronous expression evaluated in the page context becomes truthy; its behavior is described in the waitForFunction API reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Navigation response and error statuses

page.goto() returns the main-resource response, or may return null in special cases. A valid HTTP error status such as 404 or 500 does not necessarily throw, so checking response.ok() catches unsuccessful HTTP responses where a response is present. Puppeteer also warns that headless shell does not support PDF navigation. See the Page.goto reference for those navigation details.

Best Value
Sale
HP LaserJet Pro 3101sdw | Monochrome | Laser Printer | All-in-One | Duplex
  • FROM AMERICA'S MOST TRUSTED PRINTER BRAND – Perfect for small teams printing professional-quality black-and-white documents and reports. Print speeds up to 35 ppm black.
  • PROFESSIONAL PRODUCTIVITY – Proficiency with every print—bring your business to life with toner designed for sharp, professional-quality prints
  • UPGRADED FEATURES – Fast printing, scanning and copying, auto 2-sided printing, a 250-sheet input tray and 50-sheet auto document feeder
  • AWARD-WINNING RELIABILITY – Performance you can count on page after page, and always ready for the high demands of business
  • WIRELESS PRINTING – Stay connected with our most dependable Wi-Fi, which looks for the best connection to stay online
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot missing fonts or unexpected PDFs

  • The PDF uses a fallback font: Keep waitForFonts: true enabled. If the page is in the background, call page.bringToFront() before page.pdf(). If fonts depend on a later application state, wait for that state as well.
  • The page looks different from the browser: PDF generation uses print media by default. Call page.emulateMediaType('screen') first only when screen styling is intended; otherwise check the site’s print CSS.
  • Background colors or images are missing: Set printBackground: true. For exact CSS colors, use -webkit-print-color-adjust in the page’s print styling.
  • Navigation appears successful but the site returned an error page: Inspect the response from page.goto() and check response.ok() or the status code. HTTP error statuses may not reject navigation.
  • The PDF call times out: The documented PDF timeout default is 30,000 milliseconds. Review the page’s loading behavior and configure the page’s default timeout settings if a longer PDF operation is appropriate.
  • Content is missing despite a successful navigation: Wait for the relevant selector or application condition with page.waitForFunction(). Network idleness and font readiness do not prove that every app-specific render step has finished.

Or skip the browser setup

If your goal is a screenshot rather than a PDF, ScreenshotNeo returns a screenshot from one GET request. Its PDF endpoint and options are documented at ScreenshotNeo docs.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; those cleanup steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers identify the page verdict and billing status. An MCP server provides screenshot and PDF tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan.

Frequently Asked Questions

Does Puppeteer wait for web fonts before creating a PDF by default?

Yes. The documented PDFOptions API says waitForFonts defaults to true and waits for document.fonts.ready.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Does networkidle2 mean fonts are ready?

No. It is a navigation wait condition; font readiness is handled separately by waitForFonts.

Quick Recap

Bestseller No. 2
Canon imageCLASS MF273dw - Monochrome Wireless Laser Printer, Multifunction With Scanner, Copier, Auto Document Feeder, With 1 Year Limited Warranty, 30 PPM, Black
Canon imageCLASS MF273dw - Monochrome Wireless Laser Printer, Multifunction With Scanner, Copier, Auto Document Feeder, With 1 Year Limited Warranty, 30 PPM, Black
Wireless 3-in-1: Print | Copy | Scan; Print up to 30 Pages Per Minute (BW, Letter); First Print Out in Approximately 5.3 Seconds (Letter)
SaleBestseller No. 3
HP Laserjet MFP M140w Wireless Black & White Printer, Print, scan, Copy, Fast speeds, Easy Setup, Mobile Printing, Best-for-Small Teams
HP Laserjet MFP M140w Wireless Black & White Printer, Print, scan, Copy, Fast speeds, Easy Setup, Mobile Printing, Best-for-Small Teams
FAST PRINT SPEEDS – Up to 21 black-and-white pages per minute single-sided; WIRELESS WITH SELF-RESET – Helps you stay connected
$169.00
Bestseller No. 4
HP LaserJet MFP M235sdw | Monochrome | Laser Printer | All-in-One | Duplex
HP LaserJet MFP M235sdw | Monochrome | Laser Printer | All-in-One | Duplex
DUAL-BAND WI-FI WITH SELF-RESET – Automatically detects and resolves connectivity issues
$179.00

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.