October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Chrome Headless

How to Download a PDF from Print Preview with Puppeteer

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

Use Puppeteer’s page.pdf() method to create a PDF from a rendered web page. Pass a path to save a file, or omit it and handle the returned PDF bytes in your application. This is the documented Puppeteer workflow for page-to-PDF generation; it does not automate Chrome’s visible print-preview dialog or extract a file produced by that interactive interface.

The distinction matters. “Print preview” can mean the page’s print representation, which page.pdf() generates, or Chrome’s on-screen preview window, which the official Puppeteer PDF APIs do not document as a downloadable-output workflow.

Decide which PDF job you actually need

Generate a PDF of an HTML page

For a page you control or have opened with Puppeteer, call page.pdf(). Puppeteer renders the page and returns a PDF. Its documented description is “Generates a PDF of the page with the print CSS media type.” See the Page.pdf() API documentation and the official PDF-generation guide.

Capture Chrome’s interactive print-preview result

The visible Chrome print-preview interface is a separate UI flow. The Puppeteer references do not document a supported method that clicks that dialog and downloads its resulting file. If your goal is a reliable downloadable PDF, generate it directly with page.pdf() and then save or return the bytes yourself.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Epson Workforce ES-50 Compact & Lightweight Mobile Document Scanner
  • PORTABLE SCANNER FOR USE ON-THE-GO — The fastest and lightest mobile single-sheet-fed compact document scanner in its class¹
  • QUICK DOCUMENT SCANNING ― This Epson ultra-fast scanner scans a single page as quickly as 5.5 seconds²; Windows and Mac compatible
  • VERSATILE PAPER HANDLING ― Portable scanner scans documents up to 8.5 x 72 in; Also easily digitizes receipts and ID cards to make accounting, bookkeeping, and organizing simpler
  • INTUITIVE, HIGH-SPEED SOFTWARE — Epson ScanSmart Software³ is a smart tool allowing you to easily scan, review, and save; Stay organized easily with the help of this Epson scanner
  • EASY SETUP — USB-powered connect to your computer for quick and simple scanning; No batteries or external power supply required to operate portable document scanner; Standard Connectivity: USB 2.0

Download an already-existing PDF

An HTML page rendered to PDF is different from an existing PDF opened in Chrome’s PDF viewer. The Page.pdf() documentation describes rendering page content; it does not establish a method for downloading an already-open PDF viewer document. For an existing PDF, obtain the original URL or use your application’s normal HTTP download logic.

Minimal Puppeteer example: save a PDF file

Install Puppeteer in a Node.js project, then run this complete example:

const puppeteer = require('puppeteer');

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

    // Writes page.pdf() output relative to the process working directory.
    await page.pdf({path: 'page.pdf'});
    console.log('Saved page.pdf');
  } finally {
    await browser.close();
  }
})();

waitUntil: 'networkidle2' is a useful starting point, not a guarantee that every application’s asynchronous data has finished. Add page-specific readiness checks when content arrives after navigation.

Return PDF bytes instead of writing a file

Omit path and Puppeteer returns a Uint8Array. That lets an HTTP handler, object-storage client, or job queue decide how to deliver the document.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const puppeteer = require('puppeteer');

async function renderPdf(url) {
  const browser = await puppeteer.launch();
  try {
    const page = await browser.newPage();
    await page.goto(url, {waitUntil: 'networkidle2'});
    const pdfBytes = await page.pdf({
      format: 'A4',
      printBackground: true
    });
    return pdfBytes; // Uint8Array
  } finally {
    await browser.close();
  }
}

renderPdf('https://example.com').then(bytes => {
  console.log(`Generated ${bytes.byteLength} bytes`);
});

When sending those bytes over HTTP, set the response headers and download behavior in your own application. Puppeteer’s PDF method supplies the bytes; it does not prescribe your application’s storage or HTTP headers. The Page API also lists createPDFStream() for applications that benefit from a stream; check the API for the Puppeteer version installed in your project: Page class.

Rank #2
Sale
Brother DS-640 Compact Mobile Document Scanner, (Model: DS640)
  • FAST SPEEDS - Scans color and black and white documents a blazing speed up to 16ppm (1). Color scanning won’t slow you down as the color scan speed is the same as the black and white scan speed.
  • ULTRA COMPACT – At less than 1 foot in length and only about 1. 5lbs in weight you can fit this device virtually anywhere (a bag, a purse, even a pocket).
  • READY WHENEVER YOU ARE – The DS-640 mobile scanner is powered via an included micro USB 3. 0 cable allowing you to use it even where there is no outlet available. Plug it into you PC or laptop and you are ready to scan.
  • WORKS YOUR WAY – Use the Brother free iPrint&Scan desktop app for scanning to multiple “Scan-to” destinations like PC, Network, cloud services, Email and OCR. (2) Supports Windows, Mac and Linux and TWAIN/WIA for PC/ICA for Mac/SANE drivers. (3)
  • OPTIMIZE IMAGES AND TEXT – Automatic color detection/adjustment, image rotation (PC only), bleed through prevention/background removal, text enhancement, color drop to enhance scans. Software suite includes document management and OCR software. (4)

Control print and screen appearance

Print CSS is the default

page.pdf() uses the print CSS media type by default. Rules inside @media print therefore apply, and elements hidden for printing will not appear. To render the screen design instead, switch media before generating the PDF:

await page.emulateMediaType('screen');
const pdfBytes = await page.pdf();

Use this only when the screen layout is the intended output. Otherwise leave the default print media active and maintain a dedicated print stylesheet.

Paper, orientation, margins and page ranges

The PDF options support a paper format or explicit dimensions, portrait or landscape orientation, margins, page ranges, scale, background graphics, and CSS page-size precedence. For example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const pdfBytes = await page.pdf({
  format: 'A4',
  landscape: false,
  margin: {
    top: '16mm',
    right: '14mm',
    bottom: '16mm',
    left: '14mm'
  },
  pageRanges: '1-3',
  printBackground: true,
  preferCSSPageSize: true
});
  • format: choose a standard paper size such as A4.
  • width and height: use explicit dimensions when a custom page is required.
  • landscape: rotate the output for wide content.
  • margin: reserve printable space on each edge.
  • pageRanges: restrict output to ranges such as 1-3.
  • printBackground: include CSS backgrounds and images; it is off by default.
  • preferCSSPageSize: let CSS @page rules take priority over the selected format or dimensions.

These options are defined in the PDFOptions API documentation. A page’s CSS can still cause clipping or unexpected breaks, so inspect the generated file rather than assuming the browser viewport and paper dimensions match.

Preserve colors when print CSS changes them

Print rendering may alter colors. If exact colors matter, use the CSS property -webkit-print-color-adjust in the page’s stylesheet and verify the result in the generated PDF. Screen colors and print colors are not automatically identical.

Rank #3
Canon imageFORMULA R10 - Portable Document Scanner, USB Powered, Duplex Scanning, Document Feeder, Easy Setup, Convenient, Perfect for Mobile Users, White
  • STAY ORGANIZED – Easily convert your paper documents into digital formats like searchable PDF files, JPEGs, and more.Power Consumption : 2.5W or less (Energy Saving Mode: 0.7W). Suggested Daily Volume : 500 scans..Does it contain liquid: no
  • CONVENIENT AND PORTABLE –lightweight and small in size, you can take the scanner anywhere from home offices, classrooms, remote offices, and anywhere in between
  • HANDLES VARIOUS MEDIA TYPES – Digitize receipts, business cards, plastic or embossed cards, reports, legal documents, and more
  • FAST AND EFFICIENT – No technical hurdles or complicated setups here; easily scan both sides of a document at the same time, in color or black-and-white, at up to 12 pages-per-minute, and with a 20 sheet automatic feeder
  • BROAD COMPATIBILITY – Works with both Windows and Mac devices, be it laptop or computer

Make sure the page is ready before printing

Navigation readiness

The guide’s networkidle2 example waits for low network activity, but analytics, polling, lazy data requests, and client-side rendering can continue afterward. Add an explicit selector wait when a known element marks completion:

await page.goto('https://example.com/report', {waitUntil: 'domcontentloaded'});
await page.waitForSelector('#report-ready', {timeout: 30000});
await page.pdf({path: 'report.pdf', format: 'A4'});

You can also wait for a deliberate delay when a third-party widget has no reliable selector, but a deterministic selector or application event is preferable.

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

Fonts

Puppeteer’s PDF generation waits for fonts by default. The PDF options documentation lists waitForFonts as enabled by default. If the page is in the background, the option notes that bringing it to the front may be necessary for document.fonts.ready to resolve. If you see fallback fonts, test font loading explicitly:

await page.bringToFront();
await page.evaluate(() => document.fonts.ready);
await page.pdf({path: 'fonts-ready.pdf'});

Timeouts and stalled pages

The documented default PDF timeout is 30,000 milliseconds (Puppeteer PDFOptions documentation, current page accessed 2026). Set a longer timeout only when your page legitimately needs it, and fix stalled resources rather than masking a permanent failure.

Validate the output before delivering it

  • Open the PDF and check paper size, orientation, margins and page count.
  • Look for clipped wide tables, overflowing code blocks and awkward page breaks.
  • Confirm that fonts loaded and that print-only or screen-only elements are intentional.
  • Verify background graphics when the design depends on them; enable printBackground.
  • Check images loaded, especially lazy images that appear only after scrolling or intersection events.
  • Test authenticated pages with the same cookies, headers and permissions used in production.

For long documents, use CSS @page, print-specific break rules and a stable content-ready signal. Keep the browser lifecycle in a try/finally block so failures do not leave Chromium processes running.

Rank #4
IRIScan Express 4 Black Compact Portable USB Simplex Document Scanner, 8 PPM for Contracts, Invoices and Business Cards, Compatible with Windows, Readiris PDF Included
  • IRIScan Express, portable scanner : scans color and black and white documents a blazing speed up to 8ppm simplex. Color scanning won’t slow you down as the color scan speed is the same as the black and white scan speed.
  • IRIScan Express mobile scanner is powered via an included micro USB 2. 0 cable allowing you to use it even where there is no outlet available. Plug it into you PC or laptop and you are ready to scan. USB cable provided. AC Adapter not provided and not needed.
  • IRIScan flatbed scanner uses a simplex scanning mode allows for quick and straightforward scanning of single-sided documents. IRIScan with its full portable features is the ideal document scanners for computers.
  • IRIScan document scanner : Versatile scanning capabilities, including scanning to Word, PDF, and Excel formats with companion software provided Readiris OCR
  • Receipt scanner and card scanner with Additional features include scanning business cards directly to Outlook, photo scanning, and receipt scanning for efficient document management
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common failures and fixes

The PDF is blank or missing content

The page may still be rendering when page.pdf() runs. Wait for a content selector, application readiness event or required fonts. Also check whether content is hidden by print CSS.

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

Backgrounds or logos are absent

Set printBackground: true. If a logo is a CSS background, this option is required; an ordinary foreground image follows the page’s normal loading rules.

The layout looks different from the browser

PDF generation uses print media by default. Call page.emulateMediaType('screen') for screen styling, or correct the page’s print stylesheet. Check preferCSSPageSize and explicit margins when CSS and JavaScript settings conflict.

Fonts never finish loading

Bring the page to the front, await document.fonts.ready, and confirm that font URLs are reachable from the browser process. A blocked cross-origin font can leave the page with fallback typography.

Pages are clipped or unexpectedly split

Use a suitable paper format or custom dimensions, adjust margins and scale, and add print break rules in CSS. Wide content often needs landscape orientation or a responsive print layout rather than a smaller scale.

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.
Best Value
Canon Canoscan Lide 300 Scanner (PDF, AUTOSCAN, Copy, Send)
  • Scanner type: Document
  • Connectivity technology: USB
  • With Auto Scan Mode, the scanner automatically detects what you're scanning
  • Digitize documents and images

page.pdf() times out

Inspect slow or never-ending resources and page scripts. Increase the timeout only after confirming the page is expected to take longer; otherwise fix the readiness condition or resource that is blocking completion.

You need a browser download, not a rendered PDF

If the source is already a PDF, do not render the viewer page with page.pdf(). Resolve the original PDF URL and download it through your HTTP client, subject to that server’s access controls.

Chrome’s command-line alternative

When you need command-line PDF generation rather than browser control, Chrome Headless documents the --print-to-pdf option. See the Chrome Headless command-line reference. This does not change the distinction between direct PDF generation and automating the visible print-preview dialog.

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server when you want a hosted capture instead of managing Chromium. One GET request returns a PNG, JPEG, WebP or PDF. The API accepts the page URL and handles the browser work:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for output and option details. Equivalent requests in Python and Node.js are:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Before capture, ScreenshotNeo accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed as clean shots, and the response identifies the page verdict and billing result in X-Page-Verdict and X-Billed headers. Its MCP server includes take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

Frequently Asked Questions

Does Puppeteer click Chrome’s Save to PDF button?

No. The documented Puppeteer workflow is direct PDF generation with page.pdf(), not automation of the visible print-preview dialog.

What does page.pdf() return when no path is supplied?

It returns PDF bytes as a Uint8Array, which your application can store or send through its own delivery pipeline.

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

Can I generate only selected pages?

Yes. Use the pageRanges PDF option, such as 1-3, and verify the resulting page count.

Quick Recap

Bestseller No. 3
Canon imageFORMULA R10 - Portable Document Scanner, USB Powered, Duplex Scanning, Document Feeder, Easy Setup, Convenient, Perfect for Mobile Users, White
Canon imageFORMULA R10 - Portable Document Scanner, USB Powered, Duplex Scanning, Document Feeder, Easy Setup, Convenient, Perfect for Mobile Users, White
BROAD COMPATIBILITY – Works with both Windows and Mac devices, be it laptop or computer; This product is not intended for scanning photographs on photo paper / photographic media
$184.00
Bestseller No. 4
IRIScan Express 4 Black Compact Portable USB Simplex Document Scanner, 8 PPM for Contracts, Invoices and Business Cards, Compatible with Windows, Readiris PDF Included
IRIScan Express 4 Black Compact Portable USB Simplex Document Scanner, 8 PPM for Contracts, Invoices and Business Cards, Compatible with Windows, Readiris PDF Included
Find our Software here : irislink.com/start; IRIScan Express is only compatible Windows platform and not macintosh
$129.00
Bestseller No. 5
Canon Canoscan Lide 300 Scanner (PDF, AUTOSCAN, Copy, Send)
Canon Canoscan Lide 300 Scanner (PDF, AUTOSCAN, Copy, Send)
Scanner type: Document; Connectivity technology: USB; With Auto Scan Mode, the scanner automatically detects what you're scanning
$75.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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Read next

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.