Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallFor print-oriented documents built from HTML and CSS, start with WeasyPrint: its Python API can render an HTML string, file, or URL to PDF. If you need a real browser to render an existing page, use Playwright’s Python API and page.pdf(). Neither choice guarantees identical support for every modern browser feature, so test the CSS, fonts, images, and page breaks your document actually uses.
Choose a renderer for the document you have
The key choice is not simply “which library supports HTML5 and CSS3?” It is whether your application is composing a document for print, exporting a browser-rendered page, or constructing a PDF with a layout model of its own. The available documentation describes capabilities and behavior, not a universal winner for fidelity or speed.
| Option | Best fit | What to account for |
|---|---|---|
| WeasyPrint | Print-oriented documents authored as HTML and CSS | Python API writes PDFs; CSS support has documented limits, and resource fetching and untrusted markup require attention. WeasyPrint First Steps and API reference |
| Playwright for Python | Exporting an existing page or a workflow that needs browser-based rendering | page.pdf() uses print media by default. Screen-media rules and print color behavior may need deliberate handling. Playwright Page API |
| ReportLab | Programmatically composed PDFs where browser-like HTML conversion is not central | Its guide documents RML and the rml2pdf workflow; this is a different approach from directly rendering a website’s HTML/CSS. ReportLab user guide |
For the common case—an invoice, report, or other print layout you control—WeasyPrint is a practical first choice. If the page already exists in a browser workflow and relies on browser rendering, Playwright may fit better. Choose ReportLab when you want to construct the PDF through its own document model rather than convert a web page.
Generate a PDF with WeasyPrint
Install WeasyPrint using the current instructions for your operating system and Python environment. Its installation requirements can vary by platform; the documentation linked here is the place to check the prerequisites for the environment you deploy. No specific package version or minimum Python version is established here.
#1 Best Overall
- 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.
The smallest working example passes the markup explicitly with string= and writes the PDF to a file:
from weasyprint import HTML
html = """
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Report</title>
<style>
@page { size: A4; margin: 18mm; }
body { font-family: sans-serif; color: #222; }
h1 { font-size: 24pt; }
</style>
</head>
<body>
<h1>Quarterly report</h1>
<p>Generated from Python and HTML.</p>
</body>
</html>
"""
HTML(string=html).write_pdf("report.pdf")
Using HTML(string=...) matters: the documentation warns that a bare string argument can be interpreted as a filename. The API also accepts a filename, URL, or readable object. For example, to render a saved document, use HTML(filename="report.html").write_pdf("report.pdf"); to render a URL, pass its URL through the documented URL input. Pick the input form that matches how your application obtains the HTML.
Keep the document’s CSS and assets available
For a standalone document, inline CSS is straightforward. For a larger template, supply stylesheets using the documented API and keep track of the document’s base URL so relative paths resolve as intended. Images, stylesheets, and fonts can change the result; a PDF that opens successfully can still have missing assets or unexpected layout if those resources were not reachable during rendering.
WeasyPrint can load local and HTTP resources. Its default HTTP client does not handle advanced cookies or authentication. If a resource requires credentials or special fetching behavior, use an appropriate custom URL fetcher rather than assuming the default fetcher can access it. Review the API reference’s URL and CSS notes for the constraints relevant to your inputs.
Rank #2
- 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.
Use web fonts deliberately
If your CSS uses @font-face, ensure the font files are available to the renderer and configure fonts as part of the HTML-and-CSS rendering flow. WeasyPrint’s First Steps documentation demonstrates using a FontConfiguration. Verify the resulting PDF in the same environment where production rendering will run; a font available on a developer’s machine may not be available on a deployment host.
Use Playwright when browser rendering is the better fit
Playwright’s page.pdf() produces a PDF using print CSS media by default. That means @media print rules apply unless you change the emulated media before export. The following example opens a page, waits for its load event, and saves the PDF:
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
page.goto("https://example.com", wait_until="load")
page.pdf(path="page.pdf", format="A4", print_background=True)
browser.close()
Install and configure Playwright and its browser binaries according to its current Python installation documentation. The snippet uses the synchronous Python API. For an asynchronous application, use the corresponding async API and await the navigation and PDF calls.
Choose print or screen media consciously
If you want screen styles rather than print styles, call page.emulate_media(media="screen") before page.pdf(). Conversely, leave the default print media in place when the page is designed for paper. The setting affects which CSS rules apply, so a screen-looking page is not automatically the right print document.
Rank #3
- 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.
Check color output
Playwright documents that PDF generation changes colors for printing by default. If exact CSS colors matter, its documentation points to -webkit-print-color-adjust as the control to investigate. Apply it deliberately to the relevant elements, then inspect the exported PDF; color adjustment cannot correct other layout differences between screen and print styles.
Wait for the content you need
Do not export before your application has populated the page and its essential assets are ready. The Playwright API reference establishes the PDF behavior, but readiness conditions are application-specific: a static page may be ready at navigation load, while a page that fetches data or renders charts may need an explicit wait for a selector or application signal. Set and test that condition in your own workflow rather than relying on an arbitrary delay.
What “HTML5 and CSS3 support” means in practice
HTML and CSS standards are broad, and a renderer’s support is not the same as complete parity with every current browser. WeasyPrint documents broad support for many W3C CSS specifications, but also lists unsupported features and print-specific limits. Its CSS 2.1 support has exceptions, including right-to-left or bidirectional text and some table and page-box cases. Consult the current support reference for any feature your layout depends on; do not infer support merely from the label “CSS3.”
Before committing to a renderer, make a representative test document containing the hardest parts of your actual output: long tables, page breaks, headers or footers, non-Latin text, web fonts, images, and the CSS features your templates rely on. Inspect the generated PDF, not just the HTML in a browser. The documentation’s feature list narrows what to test, but cannot prove that your particular combination renders as intended.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Rank #4
- 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
Security, reliability, and operating cost
Do not render arbitrary untrusted markup without controls
WeasyPrint explicitly warns: “Using WeasyPrint with untrusted HTML or untrusted CSS may lead to various security problems.” Treat user-supplied markup and styles as a security boundary. Sanitize or constrain inputs, control which local files and network resources the renderer can fetch, and avoid exposing sensitive services or files through resource URLs. The exact safeguards depend on your application and deployment.
Make external resources predictable
A PDF render can fail or look incomplete if a stylesheet, image, or font cannot be fetched. Relative URLs depend on a suitable base location; protected resources may require a custom fetching approach. For reliable production output, keep assets under your control where practical, validate that they are reachable in the deployment environment, and check logs and the PDF when output differs from expectation.
Reuse processes for repeated WeasyPrint work
For workloads that generate many documents, WeasyPrint notes that a long-lived process can avoid repeated startup costs. That is an operational consideration, not a published throughput guarantee: do not assume a particular speed advantage without measuring your own templates, assets, and deployment. Keep rendering isolated and resource-limited according to your application’s security and reliability needs.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshooting common PDF problems
- The renderer says a string is a file path: pass markup as
HTML(string=html), rather than as a bare positional string. - An image, stylesheet, or font is missing: check its resolved URL, deployment availability, and whether it requires authentication. Use the documented fetching options where the default HTTP client is insufficient.
- The PDF differs from the browser view: confirm the renderer supports the CSS features involved, inspect print-specific styles and page breaks, and compare a representative output in the target environment.
- Playwright omits screen-only styling: its PDF operation defaults to print media. Emulate screen media before calling
page.pdf()if that is the intended output. - Backgrounds or colors look different in a Playwright PDF: account for print color behavior and review the documentation’s
-webkit-print-color-adjustguidance. - Content is absent or unfinished: make the navigation and application-specific readiness condition explicit before PDF export; do not assume a page’s initial response means its dynamic content has finished.
- Output is unsafe or reaches unexpected resources: treat untrusted HTML/CSS and URL fetching as security-sensitive; constrain input and resource access before rendering.
Or skip the browser setup
If what you need is a PDF capture of a webpage—not a locally composed PDF document—ScreenshotNeo provides a one-request screenshot API and PDF output. This is a different workflow from rendering your own HTML string with WeasyPrint or exporting a Playwright page; consult the ScreenshotNeo API documentation for PDF output settings.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Best Value
- 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.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. It also provides an MCP server for AI agents, and its free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up free for ScreenshotNeo.
Which approach should you use?
Use WeasyPrint when your input is a document you control and your goal is a print-oriented HTML/CSS PDF. Use Playwright when the output should reflect a browser page and its rendering workflow. Consider ReportLab when HTML conversion is incidental and your application is constructing a PDF through a dedicated PDF layout workflow. In all cases, validate the actual output and dependencies in the environment that will produce the final files.
Frequently Asked Questions
Can WeasyPrint convert a URL directly to PDF?
Yes. Its API accepts a URL as an input; account for relative assets and any authentication or custom fetching the page requires.
Does Playwright use print styles when creating a PDF?
Yes. Its Python `page.pdf()` uses print media by default; call `page.emulate_media(media=”screen”)` first when screen media is intended.
Is ReportLab a direct HTML-to-PDF converter?
The cited ReportLab guide documents RML and the `rml2pdf` workflow, a markup-oriented PDF-generation approach rather than direct browser-like rendering of website HTML and CSS.
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.

