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.

A Playwright PDF can fail in two different ways: the file may be rejected as malformed, or it may open normally but contain a blank page, missing text, or empty image areas. Diagnose those cases separately. Use Chromium for page.pdf(), choose print or screen CSS deliberately, wait for the application’s real content-ready signal, and then review print CSS and PDF options such as backgrounds, page size, margins, and ranges.

First, identify what “invalid” means

Save the exact bytes returned by page.pdf() (or use its path option) and capture the exception, if any. Then test the file in a second PDF reader.

  • Generation failure: Playwright raises an exception and no usable file is produced. Check the browser engine, launch mode, URL, and Python traceback.
  • Unreadable file: A reader rejects the produced file. This is different from a valid PDF whose rendered page is empty; the supplied Playwright documentation and issue reports do not establish one universal byte-level corruption cause or a required repair utility.
  • Valid but blank or incomplete: The PDF opens, but print CSS hides content, the application has not finished rendering, assets are missing, or page geometry clips the result.

Record your Playwright version, bundled or channel Chromium version, operating system, Python version, and whether the browser is headless. Those details are essential when comparing behavior between machines.

Use the supported browser path

The documented PDF-generation workflow is Chromium. A July 2025 report using Playwright 1.53.0, WebKit, Ubuntu 22.04, and Python 3.10 received an error stating that PDF generation is supported only in headless Chromium (issue #2909). Treat that as a concrete, versioned report rather than a claim about every browser or future release. WebKit and Firefox can still be useful for other automation tasks, but switch to Chromium when calling page.pdf().

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch(headless=True)
    page = browser.new_page()
    page.goto("https://example.com", wait_until="load")
    page.pdf(path="output.pdf")
    browser.close()

Playwright ships Chromium builds, including headless implementations described in its browser documentation. If a container or CI runner behaves differently, record the exact browser executable and launch arguments instead of assuming the Python package alone determines the result.

Choose print CSS or screen CSS explicitly

page.pdf() uses print media by default. A page can therefore look correct in a normal browser tab but disappear in the PDF because its print stylesheet hides navigation, changes colors, collapses containers, or removes sections.

Use the default print layout

This is appropriate when the site has a deliberate print stylesheet. Inspect its @media print and @page rules if headings, tables, or images vanish.

Request the screen layout

For pages whose usable design exists only in screen CSS, emulate screen media before generating the file:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
page.emulate_media(media="screen")
pdf_bytes = page.pdf(
    path="screen-layout.pdf",
    print_background=True,
)

Check for rules that set display: none, white text on a white background, hidden overflow, zero-height wrappers, or background images that are intentionally omitted for print. These are page-specific possibilities; no single rule explains every blank PDF.

Wait for the content that must be printed

page.goto() normally waits for the load event, which includes dependent stylesheets, scripts, iframes, and images. Modern applications can still fetch API data, hydrate a component, lazy-load images, or create charts after that event. The navigation guide recommends a page-specific readiness condition rather than treating navigation completion as proof that the document is ready (navigation documentation).

Wait for a semantic marker

page.goto(report_url, wait_until="domcontentloaded")
page.locator("[data-report-ready='true']").wait_for(state="visible")
page.pdf(path="report.pdf", print_background=True)

Good markers include the final report heading, a populated table row, a “render complete” attribute supplied by the application, or a chart container whose SVG has appeared. If you control the page, add a deterministic readiness marker after data and required assets are rendered.

Do not make arbitrary sleeps your readiness strategy

A fixed time.sleep() can be too short on a slow run and wasteful on a fast one. The API documentation discourages arbitrary timeout waits, and the navigation guide discourages generic networkidle as a readiness test because analytics, WebSockets, polling, or other long-lived requests can prevent a stable idle point. A short delay can be useful for a known animation, but pair it with a selector or application state.

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.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Set PDF options that affect visible output

The Page API documents the options below. Review them when the PDF opens but is clipped, uncolored, or unexpectedly empty.

  • print_background=True: backgrounds are off by default. Enable it when a background carries text contrast, illustrations, or essential graphics.
  • Color adjustment: printing can modify colors. A page may need -webkit-print-color-adjust: exact in its CSS when exact screen colors matter.
  • Paper geometry: use format or explicit width/height. Review margin values and prefer_css_page_size=True when the document defines an @page size.
  • page_ranges: confirm that a range such as 1-2 is not excluding the content you expect.
  • scale: the documented range is 0.1 to 2. An extreme value can make content appear clipped or microscopic.
pdf_bytes = page.pdf(
    path="invoice.pdf",
    format="A4",
    margin={"top": "16mm", "right": "12mm", "bottom": "16mm", "left": "12mm"},
    print_background=True,
    prefer_css_page_size=True,
    scale=1,
)

A complete diagnostic script

This synchronous Python example uses Chromium, waits for an application marker, selects screen CSS intentionally, and writes bytes to a known path. Remove the marker wait or change its selector to match your page.

from pathlib import Path
from playwright.sync_api import sync_playwright, TimeoutError as PlaywrightTimeoutError

URL = "https://example.com/report"
OUT = Path("report.pdf")

with sync_playwright() as p:
    browser = p.chromium.launch(headless=True)
    page = browser.new_page(viewport={"width": 1440, "height": 1000}, device_scale_factor=1)
    try:
        page.goto(URL, wait_until="domcontentloaded", timeout=60_000)
        try:
            page.locator("[data-report-ready='true']").wait_for(state="visible", timeout=30_000)
        except PlaywrightTimeoutError:
            raise RuntimeError("The report never reached its ready marker")

        page.emulate_media(media="screen")
        pdf = page.pdf(
            path=str(OUT),
            format="A4",
            print_background=True,
            prefer_css_page_size=True,
            scale=1,
        )
        print(f"wrote {OUT} ({len(pdf)} bytes)")
    finally:
        browser.close()

If you need print CSS, omit emulate_media. If the page has no readiness marker, wait for a final heading or a known row count instead of adding a long unconditional sleep.

Why images or text can still be missing

Lazy-loaded images

An image may be requested only after it enters the viewport. Scroll the relevant container, wait for each image’s complete state or a page-provided ready signal, and verify that the image URL is reachable from the browser context. A successful load event does not guarantee that later lazy content exists.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Authentication and request differences

Ensure the PDF page has the same cookies, local storage, authorization headers, and URL parameters as the interactive page. A redirect to a login screen can produce a technically valid but apparently blank document.

Historical image-loss bug reports

Playwright issue #2456 described absent image areas on Windows 10 with Python 3.11.8, Playwright 1.44.0, Chromium 125.0.6422.26, screen-media emulation, networkidle, and print_background=True. A maintainer treated it as a related bug and closed it on May 30, 2024, noting that PDF printing was not a project priority. This is environment-specific historical evidence, not proof that current releases have the same defect. Reproduce with a minimal page and current Playwright and browser versions before assigning your failure to that issue.

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

Performance and reliability practices

  • Reuse a browser process for a batch, but create an isolated context or page per document so cookies and state do not leak.
  • Set explicit navigation, readiness, and PDF timeouts. Log URL, versions, selected media, options, and output size.
  • Prefer deterministic selectors and application signals over a global sleep or generic network-idle condition.
  • Keep output dimensions and scale stable for visual comparisons; changing device scale factor can change rasterized assets.
  • Retry only transient navigation or asset failures, and capture a screenshot and page console errors on the final failed attempt. Do not hide a repeatable rendering defect with unlimited retries.

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled. Only clean shots are billed: bot checks or 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. It can return PNG, JPEG, WebP, or PDF.

One GET request is enough:

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

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)

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}`);

See the ScreenshotNeo documentation for PDF settings, full-page capture, selectors, custom CSS and JavaScript, waiting rules, cookies and headers, blocking, caching, signed links, asynchronous jobs, webhooks, bulk capture, and the usage API. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to 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. Sign up free.

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

FAQ

Can I generate a PDF from a WebKit page?

Use Chromium for the documented page.pdf() workflow. A versioned WebKit report received the headless-Chromium-only error.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Does networkidle guarantee a complete PDF?

No. Application-specific readiness is more reliable because pages can render after navigation and maintain ongoing network activity.

Why does a PDF open but show no background?

Print backgrounds are disabled by default. Try print_background=True, then inspect print CSS and color-adjustment rules.

Frequently Asked Questions

Can I generate a PDF from a WebKit page?

Use Chromium for the documented page.pdf() workflow. A versioned WebKit report received the headless-Chromium-only error.

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

Does networkidle guarantee a complete PDF?

No. Application-specific readiness is more reliable because pages can render after navigation and maintain ongoing network activity.

Why does a PDF open but show no background?

Print backgrounds are disabled by default. Try print_background=True, then inspect print CSS and color-adjustment rules.

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.