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.

First identify which stage failed: WeasyPrint fetches HTML resources such as stylesheets and images, while Playwright navigates a browser page before printing it. A resource timeout, a failed navigation, an HTTP error response, and a page that has not finished rendering are different problems—and need different fixes. This guide shows how to diagnose each one, make required failures visible, and wait for the content your PDF actually needs.

Identify the renderer and the failing stage

Start by recording the library and version, how the input is supplied (URL, file, or HTML string), the complete exception or warning, and the URL of any failing resource. Then distinguish among these cases:

  • WeasyPrint resource fetch: the HTML is being rendered, but a linked stylesheet, image, or font cannot be fetched or takes too long.
  • Playwright navigation: the browser cannot reach or finish navigating to the main document, or the navigation timeout expires.
  • HTTP error response: the server responds with a status such as 404 or 500. In Playwright, that response alone does not make page.goto() throw.
  • Page readiness or script issue: navigation finishes, but JavaScript-driven content has not appeared, or a page script throws an error.

Do not begin by raising every timeout. First determine whether the delay is in the main document, a secondary resource, or application rendering.

Fix WeasyPrint resource errors and timeouts

Give HTML strings a base URL

WeasyPrint accepts a URL, filename, file object, or in-memory HTML string. When rendering a string that refers to relative CSS, image, or font paths, provide a base URL so those references can be resolved. Without one, markup that works in a browser may produce a PDF with missing assets.

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 weasyprint import HTML

html = """
<!doctype html>
<html>
  <head>
    <link rel="stylesheet" href="styles/report.css">
  </head>
  <body>
    <img src="images/chart.png" alt="Chart">
    <h1>Monthly report</h1>
  </body>
</html>
"""

HTML(string=html, base_url="https://example.com/reports/").write_pdf("report.pdf")

Use the actual directory or URL that the relative paths are meant to resolve against. If your HTML comes from a local file tree, use the corresponding local base path rather than an unrelated website URL.

Understand the default timeout

WeasyPrint’s current First Steps documentation states that its default timeout is 10 seconds for HTTP, HTTPS, and FTP resources. This is a timeout for fetching those resources—not a universal deadline for all rendering work. It does not apply to other protocols such as file://. A slow stylesheet or image may therefore trigger a fetch warning even when the main HTML is reachable.

When investigating a timeout, note the specific resource URL and check reachability from the conversion process itself. Check redirects, authentication, TLS settings, network policy, and whether relative paths resolve as intended. The default HTTP client does not provide advanced features such as cookies or authentication; when the resource requires them, use a custom URL fetcher to supply the required request behavior.

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.

Make required and optional assets fail differently

WeasyPrint normally catches fetcher errors and emits warnings, allowing rendering to continue. That can be appropriate for an optional decorative image, but it may silently produce an incomplete PDF if a required stylesheet cannot load. A custom URL fetcher can raise FatalURLFetchingError for required resources so conversion stops rather than producing a misleading document. Keep optional assets nonfatal when the PDF remains useful without them.

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

The WeasyPrint command-line interface provides --timeout, --allowed-protocols, --no-http-redirects, and --fail-on-http-errors. These options let you make timeout, protocol, redirect, and HTTP-error behavior more explicit. Verify their exact availability and behavior against the installed WeasyPrint version before adding them to a production command.

Handle Playwright navigation and readiness separately

Inspect navigation response and status

Playwright’s page.goto() waits for the load event by default. Its Python API documents a 30-second default navigation timeout, configurable on a page or browser context. But a 404 or 500 is still an HTTP response: it does not, by itself, cause page.goto() to throw. Capture the returned response and inspect its status so an error page is not accidentally saved as the intended PDF.

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.
from pathlib import Path
from playwright.sync_api import TimeoutError as PlaywrightTimeoutError
from playwright.sync_api import sync_playwright

url = "https://example.com/report"

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    page.set_default_navigation_timeout(30_000)

    try:
        response = page.goto(url, wait_until="load")
    except PlaywrightTimeoutError as exc:
        raise RuntimeError(f"Navigation timed out: {url}") from exc

    if response is None:
        raise RuntimeError(f"Navigation produced no main-resource response: {url}")
    if response.status >= 400:
        raise RuntimeError(f"Page returned HTTP {response.status}: {url}")

    page.pdf(path="report.pdf", format="A4", print_background=True)
    browser.close()

The example uses Chromium and the synchronous Python API. A timeout, invalid URL, unreachable or nonresponsive server, and failed main resource are navigation problems. A later script exception or failed image request is a different event and should be diagnosed separately.

Wait for the content the PDF needs

A completed load event does not guarantee that a modern page has finished fetching data or populating its interface. Prefer an application-specific readiness signal or a required element over simply increasing the navigation timeout. For example, if a report is ready when its heading appears:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
page.goto(url, wait_until="domcontentloaded")
page.locator("h1.report-title").wait_for(state="visible", timeout=15_000)
page.pdf(path="report.pdf", format="A4", print_background=True)

Choose the selector and timeout to match the page you control. If the page exposes a more reliable signal—such as a completed report container—wait for that and, where useful, verify its text or content before printing.

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

Playwright documents load, domcontentloaded, networkidle, and commit as navigation wait options. Its API documentation discourages treating networkidle as a readiness check; a page may keep connections open, or become quiet before the desired data is ready. Use a specific assertion or element check instead of assuming a generic event means the PDF is complete.

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

Log failures so the next run identifies the cause

Attach listeners before navigation to distinguish failed network requests from unhandled page exceptions. Playwright’s Python API exposes a weberror event for unhandled page errors, and its TimeoutError identifies an operation terminated by a timeout.

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()

    page.on("requestfailed", lambda request: print(
        "REQUEST FAILED:", request.url, request.failure
    ))
    page.on("weberror", lambda error: print(
        "PAGE ERROR:", error
    ))
    page.on("response", lambda response: print(
        "HTTP ERROR:", response.status, response.url
    ) if response.status >= 400 else None)

    page.goto("https://example.com/report", wait_until="domcontentloaded")
    page.locator("h1.report-title").wait_for(state="visible", timeout=15_000)
    page.pdf(path="report.pdf", format="A4", print_background=True)
    browser.close()

Keep these categories distinct in logs. A failed image request may explain a missing chart without indicating navigation failure; a page exception may stop an application from populating content even though the main document loaded.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.

Use this troubleshooting sequence

  1. Capture the facts: note library and installed version, input type, full warning or exception, and failing resource URL.
  2. Separate the failure stages: establish whether the main document, a subresource, or page JavaScript failed.
  3. Check access and URL resolution: verify scheme, base URL, reachability from the conversion environment, authentication, redirects, and response status.
  4. Apply the renderer-specific fix: for WeasyPrint, configure its fetch behavior and decide whether the failed asset is fatal; for Playwright, inspect navigation response and request/page error events.
  5. Wait for the actual document content: use an app-specific signal or required element before calling page.pdf().
  6. Inspect the resulting PDF: check styles, images, fonts, and dynamic content. A completed API call does not prove that the intended page was rendered.
  7. Retry selectively: use bounded retries for transient network failures, not repeated retries for invalid URLs, deterministic HTTP errors, or script exceptions that need correction.

Protect the conversion service

Rendering untrusted HTML or CSS can create security problems, particularly when the renderer is allowed to fetch external URLs. WeasyPrint recommends limiting rendering time and memory, restricting external URL access, and sanitizing or truncating user-controlled content. For a server-side converter, enforce process and network controls rather than trusting URLs embedded in documents.

Or skip the browser setup

If you already have a page URL and want a PDF without managing a browser process, ScreenshotNeo offers a website screenshot API that can return a PDF. Its API uses one GET request; the parameter names used by other screenshot APIs also work. See the ScreenshotNeo documentation for request options.

import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://example.com/report"},
    timeout=90,
)
open("report.pdf", "wb").write(r.content)

ScreenshotNeo accepts cookie or consent banners like a visitor and removes 60-plus known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers report the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients. The free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month with no card.

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

Frequently Asked Questions

Does Playwright treat an HTTP 404 as a navigation exception?

No. Check the response returned by `page.goto()` and inspect its status.

Is WeasyPrint’s 10-second timeout a limit on the whole PDF conversion?

No. The documented default applies to HTTP, HTTPS, and FTP resource fetching, not all rendering work.

Should I always wait for `networkidle` before printing?

No. Prefer an application-specific readiness signal or required element.

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.