A PDF page-load error is not always a PDF problem. First establish whether the browser navigated successfully; then check whether the resources and application state the document depends on are ready. Only after those checks should you adjust print layout. This workflow helps separate navigation failures, missing assets, timing problems, and print-CSS differences.
Why PDF generation fails even when a page appears to open
Rendering a page to PDF involves several distinct stages: the browser resolves the URL, establishes a connection, receives the main document, loads dependent resources, runs page scripts, reaches the content state you need, and applies print rules. A failure at any stage can produce an exception, an incomplete document, or a PDF that is technically created but looks wrong.
It is important to distinguish navigation failure from an HTTP error response. A certificate problem, invalid URL, timeout, unreachable server, or failed main-resource request can prevent navigation. A 404 or 500 response, by contrast, may still be returned as a navigation response that your code can inspect. Playwright documents that page.goto() may throw an error or return a main-resource response; an HTTP status by itself is not necessarily a thrown navigation exception.
A successful main-page response is not proof that the PDF has all its inputs. Fonts, stylesheets, images, scripts, API requests, and iframes may fail or still be loading. And if a page loads correctly on screen but prints blank or differently, print media and paper settings may be responsible rather than navigation.
#1 Best Overall
- INNOVATIVE CARTRIDGE-FREE PRINTING — No more dealing with lots of tiny ink cartridges; With this wireless document and photo printer each ink bottle set is equivalent to about 90 individual cartridges²
- LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; When you choose this combination printer, scanner and copier you can print up to 4,500 pages black/7,500 color³
- COLOR PRINTING — Up to 2 years of ink in the box4 (and with every replacement ink set) for fewer out-of-ink frustrations
- ZERO CARTRIDGE WASTE — By using an Epson EcoTank printer you can help reduce the amount of cartridge waste ending up in landfills
- HOME PRINTER DESIGNED FOR RELIABILITY — The Epson EcoTank ET-2800 All-in-One Supertank Color Printer creates vivid, detailed prints and documents thanks to Micro Piezo Heat-Free Technology; Fire off 10 ISO pages per minute1 to easily finish large jobs
Start with a minimal browser test
Before changing application code, test whether the browser can print a known-good page. Chrome’s headless command-line examples make a useful baseline:
chrome --headless --print-to-pdf https://developer.chrome.com/
If a bounded wait is needed, try:
chrome --headless --print-to-pdf --timeout=5000 https://developer.chrome.com/
Chrome for Developers says the –timeout flag sets the maximum wait in milliseconds before page content is captured. For a page that depends on timer-driven content, a controlled virtual-time budget can help determine whether delayed timers are the cause:
chrome --headless --print-to-pdf --virtual-time-budget=42000 https://mathiasbynens.be/demo/time
These commands are diagnostic starting points, not universal production settings. If the known-good page prints but your target does not, focus on that site’s navigation, network access, authentication, readiness conditions, or print styles. If both fail, investigate the browser installation, runtime, and host environment first.
Inspect navigation before calling the PDF method
In Playwright, retain the result of page.goto(), note the final URL, and log how long navigation took. Do not infer success solely from the absence of an exception, or infer failure solely from an HTTP status.
Free tools Windows power users keep installed
One-click scans. No signup required.
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage();
const started = Date.now();
const url = 'https://example.com';
try {
const response = await page.goto(url, {
waitUntil: 'domcontentloaded',
timeout: 30000
});
console.log({
requestedUrl: url,
finalUrl: page.url(),
status: response ? response.status() : null,
elapsedMs: Date.now() - started
});
await page.pdf({ path: 'page.pdf', format: 'A4', printBackground: true });
} catch (error) {
console.error('Navigation or PDF generation failed:', error.message);
} finally {
await browser.close();
}
})();
Use a finite timeout and record enough environment detail to reproduce the result: original and final URLs, redirect behavior, response status, elapsed time, browser version, host or container, proxy configuration, and certificate settings. Keep the navigation and PDF errors distinguishable in logs so a print failure is not misdiagnosed as a page-load failure.
Rank #2
- CARTRIDGE-FREE PRINTING — Print lab-quality photos, graphics and creative projects; Get vibrant colors and sharp text with Epson's high-accuracy printhead and Claria ET Premium 6-color inks
- INK BOTTLES — Save on photos1 and creative projects with affordable in-house printing; All-in-one printer allows you to print 4" x 6" photos for about 4 cents each vs. 40 cents with traditional ink cartridges1
- LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; Printer, scanner and copier lets you print up to 6,200 color pages³
- PRINT FOR LONGER — Up to 2 years of ink in the box² (and with every replacement ink set) for fewer out-of-ink frustrations with this wireless printer
- ZERO CARTRIDGE WASTE — Epson EcoTank printer helps reduce the amount of cartridge waste ending up in landfills; Cartridge-free printer uses high-yield ink bottles; Each replacement ink bottle set is equivalent to about 100 individual ink cartridges⁴
- SSL or certificate error: check the certificate chain and trust configuration available to the rendering environment.
- Invalid URL: include a valid scheme such as
https://and check URL encoding. - Timeout or unreachable server: investigate DNS, proxy, firewall, service health, and whether the timeout fits the page’s expected response time.
- Main-resource failure: inspect the browser error and the server-side logs for the request.
- 404 or 500 response: inspect the returned response and decide whether the error page is an acceptable document; do not assume the status alone means navigation threw.
Find missing fonts, images, scripts, and other resources
Once the main document is reachable, inspect the requests that make up the page. Log failed requests and non-success responses, paying particular attention to fonts, image files, CSS, JavaScript bundles, API calls, and iframes. A PDF can be generated from a document whose key content never arrived.
page.on('requestfailed', request => {
console.error('Request failed:', request.url(), request.failure()?.errorText);
});
page.on('response', response => {
if (response.status() >= 400) {
console.error('HTTP error response:', response.status(), response.url());
}
});
These listeners should be attached before navigation. Their output helps separate a failed resource request from a page that simply has not reached its ready state.
- Outbound traffic is blocked: allow the browser environment to reach the host serving the failed asset or API.
- Authentication is missing: copy the necessary cookies, headers, or logged-in browser state into the rendering context; a successful document request does not guarantee protected subresources are authorized.
- Local and production DNS differ: resolve the hostname from the same container or host that runs the browser.
- CORS, CSP, or certificate trust interferes: inspect browser console output and the affected server’s policies; avoid weakening security controls as a default fix.
- Lazy content has not loaded: wait for the required content or trigger the page behavior that loads it before printing.
Wait for the content your PDF actually needs
Choose a readiness condition that proves the document’s required content exists. domcontentloaded means the initial HTML has been parsed; load waits for the page’s load event. Neither necessarily means an application has finished fetching data or rendering a chart, invoice total, or table.
For dynamic pages, wait for a specific selector and, where practical, assert the expected content before printing. For example:
await page.goto('https://example.com/report', {
waitUntil: 'domcontentloaded',
timeout: 30000
});
await page.locator('[data-testid="report-ready"]').waitFor({
state: 'visible',
timeout: 15000
});
await page.pdf({ path: 'report.pdf', format: 'A4', printBackground: true });
Replace the selector with a marker that your application sets only when the PDF’s necessary content is ready. A heading alone may not be enough if data below it is still loading. Keep the readiness timeout finite and report which condition timed out.
Rank #3
- SET IT UP ONCE AND PRINT WITH CONFIDENCE. No complicated maintenance. Just easy, reliable printing you can count on.
- INK FOR YEARS. NOT MONTHS. Up to 2 years of ink included. Get thousands of pages of cartridge-free printing. More pages, less hassle
- KEEPS PRINTING WELL AFTER COMPETITORS HAVE QUIT. No complex maintenance. Sharper text, richer colors.[2] Only with HP Smart Tank
- PREMIUM SUPPORT - Strong technical expertise to solve issues faster
- THE LAST PRINTER YOU'LL EVER NEED. Enjoy years of refillable, cartridge-free printing.
Playwright documents networkidle as a wait state but discourages using it as a generic testing signal; its guidance is to rely on web assertions to assess readiness. Pages may keep connections open or make background requests, while a quiet network does not prove the content you care about rendered correctly.
Make print output match the intended page
After navigation and readiness are verified, tune PDF layout. Playwright’s page.pdf() generates output using print CSS media by default. Print-specific rules can hide content, change colors, or alter layout compared with the screen view.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11await page.emulateMedia({ media: 'screen' });
await page.pdf({
path: 'page.pdf',
format: 'A4',
printBackground: true,
margin: { top: '12mm', right: '12mm', bottom: '12mm', left: '12mm' },
preferCSSPageSize: true
});
Use emulateMedia({ media: 'screen' }) only when the screen design is the desired output. Otherwise, retain print media and correct the site’s print styles. Decide the relevant options deliberately:
- Paper dimensions: set
formator explicit width and height to match the expected page size. - Margins: set margins explicitly if browser defaults or CSS create unexpected clipping.
- Backgrounds: enable
printBackgroundwhen background colors or images are part of the intended document. - Page selection: use
pageRangeswhen only a subset of pages belongs in the output. - CSS page dimensions: use
preferCSSPageSizewhen the site’s CSS defines the paper size you want respected.
A PDF that is blank, clipped, missing backgrounds, or unexpectedly paginated can be a successful render with unsuitable print settings. Diagnose that separately from navigation and resource loading.
Troubleshooting by symptom
| Symptom | Likely area | What to check |
|---|---|---|
| Navigation throws before a PDF is created | URL, certificate, network, or main document | Validate the scheme and certificate chain; inspect DNS, proxy and firewall access; record the navigation error and server logs. |
| A 404 or 500 page is printed | HTTP response handling | Inspect the navigation response status and decide whether to stop, retry, or intentionally capture the error page. |
| PDF is blank although navigation returned | Readiness or print CSS | Wait for a content-specific marker; inspect print styles and test screen media if that is the intended appearance. |
| Text, images, or charts are missing | Subresource failure or incomplete loading | Log failed requests and error responses; verify credentials and outbound access; wait for lazy-loaded or application-rendered content. |
| PDF looks unlike the browser screen | Print media or paper settings | Check print CSS, media emulation, paper dimensions, margins, backgrounds, page ranges, and CSS page-size preference. |
| Capture sometimes works and sometimes times out | Unbounded assumptions about network or application timing | Use a finite timeout, log elapsed time and failed requests, and wait for a deterministic application-ready condition rather than arbitrary network quiet. |
Or skip the browser setup
If operating headless Chrome is not the right fit, ScreenshotNeo is a website screenshot API that can return a PDF as well as PNG, JPEG, or WebP. Its one-call request is:
Rank #4
- Wireless Bluetooth Printer: Portable thermal printer compatible with iPhone, Android phones, iPad and tablet computers via Bluetooth. For smartphones, please download the "Nada Print" App. You can also connect to laptops and computers for printing using a USB-C cable. (Note: Laptops and computers can only be connected via USB and require the installation of a driver first. Bluetooth connection is not supported.)
- No-ink printing: Only supports US Letter and A4 size thermal paper.(Doesn't support regular paper) The no-ink portable thermal printer uses direct thermal technology, requiring no ink, toner or ribbons, making it environmentally friendly, cost-effective and time-saving. The thermal printer package comes with a roll of US Letter thermal printing paper. Note: When installing the paper, remember to switch the paper size switch on APP
- Clear Print: NDYIN N80 portable thermal printer adopts high-definition printing technology, with a 203DPI resolution to provide you with clear printing results. This mobile printer is compatible with roll paper, folded paper and tattoo transfer paper, supporting printing from your mobile phone PDF, Word, pictures and web pages anytime and anywhere. It is recommended to use our NDYIN thermal paper to achieve good printing quality
- Portable wireless printer for travel: The thermal printer is equipped with a built-in 1500mAh rechargeable battery, which can print 160 sheets of 8.5" x 11" thermal paper after being fully charged. It weighs only 1.5 pounds and is compact in size. This ink-free portable printer can be easily carried in a backpack or briefcase! It is perfect for business travel, cars, small offices, construction sites, schools and homes. You can print documents, contracts, invoices and boarding passes anytime and anywhere
- The N80 thermal printer has a wide range of uses. The package includes the N80 printer, a roll of US Letter paper(7m/roll), a user manual, a guide card, a type-C soft cable and a type C adapter. Note: The charging adapter is not included. Special thermal paper is required for use; ordinary paper cannot be used. This ink-free portable thermal printer is suitable for various scenarios such as home, school, travel, office, and outdoor, meeting the printing needs of different groups of people. This tattoo template printer is also compatible with tattoo transfer paper, making it an ideal choice for tattoo art
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 request options and PDF settings. The response indicates whether a capture was a cache hit, failed load, blank page, bot check, or successful page, and only clean shots are billed. Cookie and consent banners, newsletter popups, and chat widgets are removed before capture; each cleanup step can be disabled. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsThe Free plan includes 1,000 screenshots per month with no card required; paid plans start at $5 for 3,000 screenshots. Sign up for 1,000 free screenshots a month, with no card required.
Performance, reliability, and cost considerations
For an in-house browser workflow, total time includes navigation, subresource loading, application readiness, and PDF rendering. A larger timeout can accommodate slow pages, but it also makes each failed job take longer; keep it finite and log the stage that consumed it. Waiting for a concrete selector can avoid both premature captures and unnecessary waiting after the needed content appears.
For repeatable results, keep the browser version and execution environment consistent, and record proxy, DNS, and certificate configuration. If jobs run in parallel, account for the fact that each browser session uses machine resources; set concurrency according to the limits of the host rather than relying on a single successful local run.
There is no universal cost figure for self-hosted rendering: it depends on browser infrastructure, traffic, operations, and retries. A hosted renderer trades some control over the runtime for reduced browser setup. Compare navigation status and request visibility, readiness controls, JavaScript support, print-media fidelity, authentication and network options, reproducibility, resource limits, and price for the workload you actually have.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Frequently Asked Questions
Does a 404 mean Playwright navigation failed?
Not necessarily. A 404 can be returned as a main-resource response; inspect the response status separately from navigation exceptions.
Should I always wait for networkidle before printing?
No. Prefer a selector or assertion that proves the content needed for the PDF is ready.
Why does page.pdf() not match my screen design?
Playwright uses print CSS media by default, so print styles and paper settings can change the result.
Quick Recap
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.

