October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Alpine Linux

How to Fix Puppeteer’s Page.printToPDF “Printing Failed” Error

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

The quickest reliable fix is to isolate the failure before changing code: reproduce it with a tiny page, record the Puppeteer and Chromium revisions, then test a known-good browser revision. If the failure is environment-specific, fix writable profile paths, Linux libraries, sandbox permissions, Alpine/Chromium compatibility, or memory and CPU limits before tuning the page itself. page.pdf() calls Chromium’s Page.printToPDF command and uses print CSS by default, so page content and print styles are only one part of the diagnosis.

What “Protocol error (Page.printToPDF): Printing failed” means

Puppeteer’s page.pdf() method asks Chromium’s DevTools Protocol to execute Page.printToPDF. Chromium must load the document, create a print layout, load required fonts, rasterize images and other assets, and write the resulting PDF. A failure at any of those stages can surface as the same protocol error.

The PDF API renders with the print CSS media type unless you explicitly select another type. If your design only works with screen styles, call await page.emulateMediaType('screen') before generating the file. The API waits for fonts by default. To preserve exact colors in print output, use the documented -webkit-print-color-adjust CSS property where appropriate.

Start with a minimal reproduction

Do not begin by changing launch flags, timeouts and page CSS simultaneously. First determine whether Chromium can print any page in the failing runtime.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
HP Printer Paper | 8.5 x 11 Paper | Copy &Print 20 lb | 1 Ream Case - 500 Sheets| 92 Bright | FSC Certified | 200060
  • HP Papers is sourced from renewable forest resources and has achieved production with 0% deforestation in North America. Each ream is wrapped in a polyurethane coated paper wrapper to protect the cut sheets from moisture damage
  • Sheet size – 8.5 x 11; Thickness – 20 pounds; Brightness – 92 bright white
  • HP Copy&Print20 20 pounds printer paper is Forest Stewardship Council (FSC) certified and contributes toward satisfying credit MR1 under LEED (Leadership in Energy and Environmental Design)
  • All HP Papers provide premium performance on HP equipment, as well as on all other printer and copier equipment; 100% satisfaction guaranteed; ColorLok technology provides more vivid colors, bolder blacks and faster drying
  • Superior quality, reliability, and dependability for high-volume printing at home, at school and in the office; HP Copy&Print20 print and copy paper prevents yellowing over time to ensure a long-lasting appearance for added archival quality
  1. Create a clean project and install the Puppeteer version you intend to test.
  2. Run this script against a short, local document:
const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  try {
    const page = await browser.newPage();
    await page.setContent(`<!doctype html>
      <html><body><h1>PDF smoke test</h1><p>Hello</p></body></html>`, {
      waitUntil: 'load'
    });
    await page.pdf({ path: 'smoke-test.pdf', format: 'A4', printBackground: true });
    console.log('Wrote smoke-test.pdf');
  } finally {
    await browser.close();
  }
})();
  1. Record the Puppeteer version, the bundled or externally supplied Chromium revision, Node.js version, operating system, container image, and every launch argument.
  2. Run the same script with your real URL. A local smoke test that fails points to the browser or runtime; a smoke test that passes narrows the problem to navigation, assets, CSS or document size.

The current Puppeteer PDF guide is version 25.12.0. Keep the guide’s basic order—launch, create a page, navigate or set content, call page.pdf(), then close the browser—while you compare environments.

Fix the browser revision before rewriting the page

Browser updates can regress PDF printing even when your JavaScript is unchanged. Puppeteer issue 10353, opened June 8, 2023, describes roughly half of a workload that worked in Chrome 113 failing in Chrome 114, with memory spikes before crashes. Issue 12470, opened May 21, 2024, reports a 30-second timeout with Chrome for Testing win64-125.0.6422.60 while win64-121.0.6167.85 succeeded; that report used Puppeteer 22.9.0, Node 18.15.0 and npm 9.5.0 on Windows.

Use those incidents as a diagnostic pattern, not as a promise that every installation has the same bug:

  • Run the minimal script with the revision that last worked.
  • Change only the browser revision and run it again.
  • If the older revision succeeds, pin it temporarily or upgrade Puppeteer and Chromium deliberately together.
  • Keep a record of the working pair so a future update can be rolled back quickly.

Do not “fix” a browser regression by adding random flags. A flag can hide the symptom while leaving a repeatable incompatibility in production.

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

Repair platform-specific failures

Windows: downloaded Chrome permissions and sandbox setup

Puppeteer’s troubleshooting guidance says downloaded Chrome files need the correct sandbox permissions on Windows. Puppeteer 22.14.0 and later attempts to configure them with Chrome’s setup tool. On an older installation, or when the problem persists, apply the documented icacls command to the Chrome cache under %USERPROFILE%/.cache/puppeteer/chrome, then rerun the smoke test as the same account that will generate PDFs.

Rank #2
Amazon Basics Multipurpose Copy Printer Paper, 8.5 x 11 Inches, 20 lb, 92 Bright, White, 1 Ream (500 Sheets), Jam-Free
  • 1 ream (500 sheets) of 8.5 x 11 white copier and printer paper for home or office use
  • Multipurpose letter size copy paper works with laser/inkjet printers, copiers and fax machines
  • Smooth 20lb weight paper for consistent ink and toner distribution; dries quickly and resists paper jams
  • Bright white paper (92 GE; 104 Euro) offers great contrast for crisp printing and vivid color
  • Virgin copy paper providing professional quality results; acid-free to prevent yellowing

Check that antivirus or endpoint controls have not removed or quarantined the downloaded browser, and avoid testing once as an administrator and once as a service account: the cache and permission results can differ.

Linux containers: make profile and cache locations writable

Chromium writes profile, configuration and cache data during startup and printing. A read-only container can launch successfully yet fail when PDF generation needs to write temporary data. Set writable locations and an explicit writable user data directory:

ENV XDG_CONFIG_HOME=/tmp/chrome-config
ENV XDG_CACHE_HOME=/tmp/chrome-cache

# In JavaScript:
const browser = await puppeteer.launch({
  userDataDir: '/tmp/chrome-profile'
});

Create those directories at startup if your image does not already contain them, and verify that the account running Chromium owns them. A writable output directory is also required for path: 'file.pdf'.

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

Linux libraries, fonts and sandboxing

Minimal CI images often omit shared libraries and fonts needed by Chrome. The troubleshooting guide specifically calls out packages including libnss3, libgbm1, GTK libraries, font packages, ca-certificates, xdg-utils and wget. Install the equivalents for your distribution, then verify the actual executable can start before investigating HTML.

Chromium’s sandbox also needs suitable privileges. The guide documents --no-sandbox as a workaround for constrained environments:

Rank #3
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 3 Reams (1,500 Sheets), 92 Bright White for Home Use
  • 3 ream case (1,500 sheets) of 8.5 x 11 white copier and printer paper for home or office use
  • Multipurpose letter size copy paper works with laser/inkjet printers, copiers and fax machines
  • Smooth 20lb weight paper for consistent ink and toner distribution; dries quickly and resists paper jams
  • Bright white paper (92 GE; 104 Euro) offers great contrast for crisp printing and vivid color
  • Virgin copy paper providing professional quality results; acid-free to prevent yellowing
const browser = await puppeteer.launch({
  args: ['--no-sandbox']
});

Use that only in an environment you trust and understand. It weakens process isolation; fixing the container’s user, permissions and sandbox support is safer for a multi-tenant or internet-facing service.

Alpine: treat the browser and distribution as a pair

Chrome is not supported on Alpine out of the box. The troubleshooting record notes timeout problems with the current Chromium package on Alpine 3.20 that were fixed by downgrading to Alpine 3.19, and recommends matching the installed Chromium version to a Puppeteer version that supports it.

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

Confirm the Alpine release, the exact Chromium package version and the Puppeteer version in the failing image. Test the same code in a supported Debian- or Ubuntu-based image; if that works, the issue is compatibility rather than your document. Do not mix a newly upgraded Alpine Chromium package with an old Puppeteer lockfile without testing.

Serverless and Cloud Run: CPU and lifecycle matter

Intermittent failures often follow resource pressure. The Chrome 114 incident reported memory spikes before crashes, so inspect the container’s memory limit and the number of simultaneous pages and PDF jobs. Reduce concurrency or give the instance more memory while you establish a stable baseline.

On Cloud Run, Puppeteer work started after the HTTP response can become extremely slow because CPU is disabled by default in that phase. Generate the PDF before sending the response, or enable CPU always for background execution. A request timeout is not proof that Page.printToPDF itself is broken; the process may simply no longer have CPU time.

Rank #4
Upload & Print 8.5x11 Custom PDF – 25 Sheets - High Resolution Full Color Printing – Premium Stock Options - Heavy Card Stock, Laminated, Etc. - Fastest Turnaround - Made in the U.S.A.
  • PREMIUM QUALITY: High-resolution full color printing on standard 8.5x11 inch sheets with professional-grade output and crisp, vibrant results
  • VERSATILE OPTIONS: Choose from multiple stock materials including paper, card stock, laminated, and double-thick variants to suit your specific needs
  • SAME-DAY SERVICE: Orders placed before 2 PM CST Monday through Friday qualify for same-day printing
  • CUSTOMIZATION: Simply upload your PDF design for personalized printing
  • AMERICAN MADE: Produced in USA facilities using premium stock, ensuring consistent quality and reliable delivery

Only then inspect navigation and page content

Once the smoke test and browser revision are stable, make the document deterministic:

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.
  • Wait for navigation and for the application’s data-fetching step to finish before calling page.pdf().
  • Wait for critical images and fonts. The PDF API waits for fonts by default, but a page that injects fonts or content late still needs an application-level readiness signal.
  • Use page.emulateMediaType('screen') only when screen CSS is intended. Otherwise keep the print default and inspect @media print rules.
  • Check header and footer templates, page ranges and very large images. Remove or resize an asset that exhausts memory.
  • Confirm that selectors used for hiding or showing content exist after the final render, not merely after the initial HTML response.

A controlled rendering sequence might look like this:

const page = await browser.newPage();
await page.goto('https://example.com/report', {
  waitUntil: 'networkidle0',
  timeout: 60000
});
await page.emulateMediaType('print'); // optional; print is the default
await page.evaluate(() => document.fonts.ready);
await page.pdf({
  path: 'report.pdf',
  format: 'A4',
  printBackground: true,
  preferCSSPageSize: true
});

Use a less strict navigation condition when a site keeps analytics or WebSocket connections open forever; otherwise networkidle0 can make a healthy page appear to hang. Prefer an explicit “report ready” selector or application flag when you control the page.

Diagnose by the symptom

Symptom Most likely area Next check
Even the local smoke test fails Browser executable, sandbox, permissions or missing libraries Run the same script with a known-good revision and inspect startup logs and writable paths.
Only one Chrome revision fails Browser regression or Puppeteer/Chromium mismatch Pin the working revision, then upgrade deliberately.
Only large or image-heavy documents fail Memory pressure or an oversized asset Measure instance memory, lower concurrency and test with images removed or resized.
It hangs until a 30-second or request timeout Navigation never reaches your wait condition, Cloud Run CPU allocation, or a browser regression Log each stage, try an explicit readiness selector, and verify CPU is available during the work.
It fails only in Docker or CI Read-only paths, missing libraries/fonts, sandbox privileges or image drift Compare the image and user with local, then set writable XDG paths and install required packages.
It fails only on Alpine Unsupported or mismatched Chromium package Test a supported base image or align Alpine, Chromium and Puppeteer versions.
PDF succeeds but looks wrong Print media CSS, fonts, page size or templates Inspect print rules, wait for fonts, and select screen media only when required.

Make a stable production pipeline

  • Pin versions: lock Puppeteer and the browser revision instead of accepting an unreviewed download on every build.
  • Log stages: record launch, navigation start/end, readiness, PDF start/end, browser revision and elapsed time. This distinguishes a navigation timeout from a print failure.
  • Control concurrency: begin with one page per browser or a small tested pool. Increase parallelism only after measuring memory under your largest documents.
  • Use bounded retries: retry a transient browser crash after collecting diagnostics, but do not loop indefinitely on a deterministic CSS or permission error.
  • Keep output and temporary paths separate: use a writable temporary profile and an output directory with cleanup rules.
  • Test upgrades as matrix changes: test the new Puppeteer, Chromium, Node.js and base image combination together, while retaining the last known-good combination for rollback.

There is no universal timeout that makes printing reliable. A timeout should exceed the slowest legitimate navigation and font/image load in your environment, while the surrounding service still has a clear upper bound and useful diagnostics.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server for developers. It accepts a URL in one request and can return PNG, JPEG, WebP or PDF output. Before capture it accepts cookie and consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers.

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

For a basic call, see the ScreenshotNeo API documentation:

Best Value
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 5 Reams (2,500 Sheets), 92 Bright White
  • 5 ream case (2,500 sheets) of 8.5 x 11 white copier and printer paper for home or office use
  • Multipurpose letter size copy paper works with laser/inkjet printers, copiers and fax machines
  • Smooth 20lb weight paper for consistent ink and toner distribution; dries quickly and resists paper jams
  • Bright white paper (92 GE; 104 Euro) offers great contrast for crisp printing and vivid color
  • Virgin copy paper providing professional quality results; acid-free to prevent yellowing
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

The same request in Python:

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)

And in Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients. Its options include full-page capture with lazy images loaded, CSS-selector element capture, dark mode, device presets and custom viewports, retina scale, PDF paper size/margins/landscape/page ranges, custom CSS and JavaScript, clicks before capture, selector hiding, selector/delay/network-idle waits, request and resource blocking, custom headers/cookies/user agents/Authorization, timezone and geolocation, transparent backgrounds, resizing, selectable-TTL caching, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API and an OpenAPI specification.

Every plan includes every feature. The Free plan provides 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots, with yearly billing giving two months free. If you want to stop maintaining a Chrome image, sandbox and font stack, sign up for the free ScreenshotNeo plan.

When to choose each remedy

  • Known-good revision succeeds: pin or upgrade the browser/Puppeteer pair and schedule a controlled regression test.
  • Only a container fails: fix writable paths, dependencies, fonts and sandbox permissions before changing application code.
  • Only large jobs fail: reduce concurrency, inspect memory and simplify oversized assets.
  • Only page-specific output fails: fix readiness, fonts, print CSS, templates or page ranges.
  • You need a managed capture service: use an API such as ScreenshotNeo when removing browser-runtime maintenance is worth the per-shot cost.

Frequently Asked Questions

Does `page.pdf()` always use print styles?

Yes. Puppeteer documents the PDF operation as using Chromium’s `print` CSS media type by default. Select `screen` with `page.emulateMediaType(‘screen’)` only when your intended design is the screen version.

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

Should I permanently add `–no-sandbox` to production?

No. It is a workaround for constrained environments and weakens isolation. First correct the container user, permissions and sandbox support; use the flag only in a trusted environment where that trade-off is understood.

Why can a retry succeed without any code change?

A retry may land on a less memory-constrained instance or avoid a transient browser crash, but repeated retries do not cure deterministic revision, permission, dependency or document-size problems. Capture stage logs and resource data before increasing retries.

Can an API replace Puppeteer for every PDF workflow?

Not automatically. A managed capture API is useful when you need screenshots or PDFs without maintaining Chromium, but Puppeteer remains the better fit when you require in-process browser automation, custom application state or logic unavailable through the service.

Quick Recap

Bestseller No. 1
HP Printer Paper | 8.5 x 11 Paper | Copy &Print 20 lb | 1 Ream Case - 500 Sheets| 92 Bright | FSC Certified | 200060
HP Printer Paper | 8.5 x 11 Paper | Copy &Print 20 lb | 1 Ream Case - 500 Sheets| 92 Bright | FSC Certified | 200060
Sheet size – 8.5 x 11; Thickness – 20 pounds; Brightness – 92 bright white
$6.97
Bestseller No. 2
Amazon Basics Multipurpose Copy Printer Paper, 8.5 x 11 Inches, 20 lb, 92 Bright, White, 1 Ream (500 Sheets), Jam-Free
Amazon Basics Multipurpose Copy Printer Paper, 8.5 x 11 Inches, 20 lb, 92 Bright, White, 1 Ream (500 Sheets), Jam-Free
1 ream (500 sheets) of 8.5 x 11 white copier and printer paper for home or office use; Virgin copy paper providing professional quality results; acid-free to prevent yellowing
$6.97
Bestseller No. 3
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 3 Reams (1,500 Sheets), 92 Bright White for Home Use
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 3 Reams (1,500 Sheets), 92 Bright White for Home Use
Virgin copy paper providing professional quality results; acid-free to prevent yellowing
$23.99
Bestseller No. 5
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 5 Reams (2,500 Sheets), 92 Bright White
Amazon Basics Multipurpose Copy Printer Paper, 20 lb, 8.5 x 11 Inches, 5 Reams (2,500 Sheets), 92 Bright White
Virgin copy paper providing professional quality results; acid-free to prevent yellowing
$29.14

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.

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

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
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver 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.