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

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

For a new Python project that turns web content into print-ready PDFs, start by evaluating WeasyPrint. It has a direct Python API and documents support for print CSS and paged-media features. Choose xhtml2pdf when its ReportLab-based workflow and PDF controls better fit your application. Use wkhtmltopdf only when you specifically need its older WebKit command-line rendering path—and treat its warning about untrusted HTML and JavaScript as a serious security requirement.

The right choice depends less on a library’s name than on how your real documents render, where its dependencies run, and whether its method of loading images, stylesheets, and other resources works in your deployment.

Which Python HTML-to-PDF library should you choose?

Option Good fit Key trade-off
WeasyPrint New print-oriented PDFs using modern CSS and paged-media layout. Requires system dependencies including Pango; its default fetcher does not provide advanced cookies or authentication.
xhtml2pdf A Python-oriented ReportLab workflow with PDF metadata, encryption, signatures, and in-memory output. Its documented CSS support is HTML5, CSS 2.1, and some CSS 3; verify that your layout fits those capabilities.
wkhtmltopdf Cases where the WebKit-based command-line conversion path is required. The official download page lists 0.12.6 as the stable series, released in 2020, and warns against converting untrusted HTML or JavaScript.

There is no authoritative cross-project benchmark establishing a universal winner for speed or rendering fidelity. Test the same representative documents with the candidates you can deploy, rather than treating a feature list as a substitute for output validation.

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

What to evaluate before choosing

CSS and page layout

Start with the document, not the API. A simple invoice with a logo and a few tables has different needs from a long report with page breaks, repeated headers, or print-specific styles. WeasyPrint is the first candidate to evaluate when the goal is modern print-oriented CSS and paged media. xhtml2pdf documents a narrower baseline—HTML5, CSS 2.1, and some CSS 3—so test advanced layout rules rather than assuming browser-equivalent rendering.

#1 Best Overall
Tengchi RCA to HDMI Converter, AV to HDMI Adapter
  • RCA Female to HDMI Video Converters Adapter : The cable is used to convert analog composite input to HDMI 1080p output, displayed on a 1080p HD TV/TV/monitor.
  • Input ports: 1xRCA Female (Yellow, White, Red), Output ports: 1xHDMI 1.3 1080p. NOT support 3D and 4K, NOT support HDMI Converts to AV
  • AV to HDMI Converter: Plug and Play, Easy to Install and Operate, Powered by External USB Cable. Note: Please hook up the USB power cable (included) to 5V 1Apower source during use (not included power supply ).
  • Support PAL, NTSC3.58, NTSC4.43, SECAM, PAL/M, PAL/N standard TV formats input. For PS2,PS3,Xbox,N64,STB, VHS, VCR, DVD Players and other devices with standard composite AV input.
  • You Will Get : 1x RCA Female TO HDMI Converter, 1xHDMI cable, 1xUSB cable, 1xUser Manual. ONE YEAR WARRANTY - if you are not satisfied for any reason whatsoever, do not hesitate to contact us .

Keep a small fixture set of actual templates and compare page count, line wrapping, image placement, links, and any clipping or overflow. Include long and short content, missing optional fields, and pages with large tables. A PDF that looks right for one sample may fail when a title wraps or a table crosses a page boundary.

Runtime and operating-system dependencies

WeasyPrint is a Python library, but it also requires native support: its current documentation lists Python 3.10 or newer and Pango 1.44 or newer. Confirm that these are available in the target operating system, container image, or deployment environment before committing to the package.

xhtml2pdf is backed by ReportLab, html5lib, and pypdf. Its project recommends the PyCairo extra or backend for current releases. wkhtmltopdf follows another model: install and operate a platform binary, then invoke it from your Python application or through a wrapper. That adds an executable and its platform compatibility to your deployment checklist.

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.

External images, stylesheets, cookies, and authentication

A converter can only render resources it can retrieve. WeasyPrint’s default URL fetcher can read file and HTTP URLs, but does not handle advanced cookies or authentication. If protected resources are required, use a controlled custom fetcher and decide explicitly which URLs and credentials it may access. Do not grant a renderer unrestricted access to internal services or arbitrary file paths.

Rank #2
ABLEWE RCA to HDMI,AV to HDMI Converter, 1080P Mini RCA Composite CVBS Video Audio Converter Adapter Supporting PAL/NTSC for TV/PC/ PS3/ STB/Xbox VHS/VCR/Blue-Ray DVD Players
  • RCA to HDMI Converter: Converts analog RCA composite (Yellow, White, Red) input to HDMI 720P/1080P (60HZ) output,displayed on HDTV/Monitor,which can bring back your childhood memories.
  • Plug to Play: ABLEWE Mini RCA to HDMI converter no extra drivers need, just plug and play,easy to use.Please hook up the USB power cable (included) to 5V power source during use.
  • Wide Compatibility: Support source formats of PAL, NTSC3.58, NTSC4.43, SECAM, PAL/M, PAL/N standard TV. Provide advanced signal processing with great precision, colors, resolutions, and details.
  • Widely Used:Widely applied to PS2,PS3,Xbox,N64, WII, STB, VHS, VCR, DVD Players and other devices with standard composite AV input.
  • Attention & Package:Please ensure to connect this rca to hdmi converter to power source to make it work.Package include:1*RCA to HDMI Converter,1*usb power cable(adapter not included),1*User Manual.

For each candidate, test the actual resource patterns in your documents: relative paths, local assets, remote images, redirects, and protected endpoints. A successful conversion that silently omits a stylesheet or image is still a failed document-generation workflow.

PDF controls and untrusted input

xhtml2pdf documents controls for metadata, encryption, signatures, resource policy, and error handling. Those controls can make it a better fit when the application needs them in its PDF-generation path. With wkhtmltopdf, the project’s official downloads page says, “Do not use wkhtmltopdf with any untrusted HTML.” Sanitize or reject user-controlled HTML and JavaScript before conversion; do not expose the binary as an unrestricted rendering service.

Convert HTML with WeasyPrint

Install WeasyPrint in a virtual environment after installing the required platform dependencies. Its documented basic flow takes an HTML string and writes a PDF:

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.
python -m venv .venv
. .venv/bin/activate
python -m pip install weasyprint

On Windows, activate the environment with .venv\Scripts\activate. The Python package installation does not by itself guarantee that Pango and other required native libraries are present; follow the WeasyPrint installation instructions for your operating system.

Rank #3
GINGIN AV to HDMI Converter, AV to HDMI Adapter Support 720p/1080p for PS1/PS2/PS3/Xbox 360/WII/N64/SNES/STB/VHS/VCR/Blue-Ray DVD Players
  • Composite to HDMI Converter: Converts analog AV composite (Yellow, White, Red) input to HDMI 720P/1080P (60HZ) output, displayed on smart TV, Projector or HD Display, which bring back your old and cherish memories.
  • Plug to Play: This HDMI Converter no extra drivers need, just plug and play,easy to use. Please hook up the USB Power Cable (included) to 5V power source during use. Note: The Video Converters only support converts AV to HDMI, can't converts HDMI to AV.
  • Widely Used: This composite to hdmi adapter is widely applied to PS1, PS2, PS3, Xbox, N64, Wii, STB, VHS, VCR, DVD Players and other devices with standard composite AV input. Note: It can only be used when PS2 is set to RGB output.
  • Wide Compatibility: This Video Audio Converter Adapter supports source formats of PAL, NTSC3.58, NTSC4.43, SECAM, PAL/M, PAL/N standard TV. Provide advanced signal processing with great precision, colors, resolutions, and details. Important Note: This converter can't improve video quality!
  • Attention & Package: Please ensure to connect this av hdmi converter to power source to make it work. Package include: 1*AV to HDMI Adaptor, 1*USB Power Cable(adapter not included), 1*User Manual.
from weasyprint import HTML

html = """
<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <style>
      @page { size: A4; margin: 18mm; }
      body { font-family: sans-serif; }
      h1 { color: #183a5a; }
    </style>
  </head>
  <body>
    <h1>Monthly report</h1>
    <p>Generated from HTML with WeasyPrint.</p>
  </body>
</html>
"""

HTML(string=html).write_pdf("out.pdf")

For HTML stored in a file, use HTML(filename="report.html").write_pdf("out.pdf"). When the markup refers to relative images or stylesheets, give the renderer a suitable base URL so it can resolve them; verify the result rather than assuming unresolved resources will stop conversion. WeasyPrint documents hyperlinks, bookmarks, attachments, forms, and raster and vector images among its supported PDF features.

Loading authenticated resources safely

The default fetcher is not a general authenticated browser session. If a document needs protected content, provide a custom fetcher that applies narrowly scoped credentials and permits only expected hosts and schemes. Restrict local file access as well. This matters both for correctness and for security: HTML that can choose arbitrary resource URLs can otherwise cause a server-side renderer to request resources the application did not intend to expose.

Convert HTML with xhtml2pdf

Install the package, then pass HTML to pisa.CreatePDF(). The destination can be a file object, which makes it possible to write to disk or an in-memory buffer.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
python -m pip install "xhtml2pdf[pycairo]"
from pathlib import Path
from xhtml2pdf import pisa

html = """
<!doctype html>
<html>
  <head><meta charset="utf-8"></head>
  <body>
    <h1>Monthly report</h1>
    <p>Generated from HTML with xhtml2pdf.</p>
  </body>
</html>
"""

output = Path("out.pdf")
with output.open("wb") as pdf_file:
    status = pisa.CreatePDF(html, dest=pdf_file)

if status.err:
    raise RuntimeError("xhtml2pdf reported conversion errors")

Check the returned status and configure exception behavior as appropriate for your application; do not treat the existence of an output file as proof that every element rendered correctly. For an in-memory result, pass a binary buffer such as io.BytesIO() as the destination, then read its contents after conversion. Consult the project documentation for the current signatures and controls for metadata, encryption, signatures, and resource policies.

Rank #4
BD&M RCA to HDMI Converter, AV to HDMI Adapter Supports PAL/NTSC for PS2, PS3, Xbox, VHS, VCR, DVD Players
  • Convert RCA to HDMI Instantly – BD&M RCA to HDMI Converter easily converts analog RCA/composite AV signals to HDMI output, allowing you to connect older devices to modern HDTVs, monitors, and projectors with clear video and audio quality.
  • Wide Device Compatibility – Supports VHS players, VCRs, DVD players, camcorders, retro gaming consoles, and more including PS1, PS2, PS3, Xbox, N64, Wii, and older AV devices with standard RCA output.
  • 1080P HDMI Output – Advanced signal processing delivers stable and sharp video output with support for 720P/1080P HDMI resolution, improving compatibility with modern TVs and displays.
  • Plug & Play Setup – No drivers or software required. Simply connect the RCA cables, HDMI cable, and included USB power cable for quick and easy installation in minutes.
  • Compact & Reliable Design – Lightweight mini converter design makes it perfect for home entertainment setups, retro gaming, travel, or converting old media collections while maintaining stable performance.

When its rendering model fits

xhtml2pdf describes itself as an HTML-to-PDF converter using Python, ReportLab, html5lib, and pypdf. Its approach can suit applications that prefer this Python library stack and its explicit PDF controls. It is not a drop-in guarantee of browser rendering: exercise your real CSS, especially if templates rely on modern layout features.

Use wkhtmltopdf when the WebKit path is necessary

wkhtmltopdf is a standalone command-line converter, not simply another Python API. Install an official platform binary, then invoke it from Python only after accounting for executable availability and input security.

import subprocess

subprocess.run(
    ["wkhtmltopdf", "report.html", "out.pdf"],
    check=True,
    timeout=60,
)

The example assumes the executable is installed and available on PATH; adjust the executable path and timeout for the deployment. Handle subprocess failures and timeouts, and inspect generated PDFs for missing assets or incomplete pages. The official downloads page identifies 0.12.6 as the stable series and dates its release to June 11, 2020. That is a version fact, not a guarantee about compatibility with current websites or a comparative quality score.

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

Because the project warns not to use wkhtmltopdf with untrusted HTML, do not pass user submissions directly into the converter. If untrusted content is part of the product, sanitize it and isolate the conversion process with appropriate operating-system permissions and resource limits.

Best Value
Convert to PDF
  • Export or Convert Text, HTML, PNG, JPG, or Camera Pictures to PDFs
  • Unlimited use
  • No ads
  • No personal data taken
  • GDPR compliant
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Test fidelity, performance, and reliability with your own documents

No authoritative source establishes a universal speed or fidelity ranking across these projects. Build a repeatable comparison around the workload your service actually handles:

  1. Choose representative inputs. Include typical templates, large documents, remote and local assets, long tables, unusual characters, and any CSS features the product depends on.
  2. Run in the target environment. Use the same operating system, container, installed fonts, dependency versions, and network rules planned for production.
  3. Check output, not only exit status. Compare page count, clipping, typography, links, images, page breaks, and PDF metadata or controls that matter to your use case.
  4. Measure the workload you expect. Record conversion time and resource use over repeated runs with identical inputs. Treat your measurements as specific to that environment and document set, not as a universal library benchmark.
  5. Exercise failure cases. Test missing resources, inaccessible endpoints, malformed HTML, timeouts, and concurrent jobs. Decide how failures are surfaced and whether a partial PDF can ever be returned to a user.

For reliability, pin package and system dependencies in the deployment and run the same fixture set when upgrading. Keep resource retrieval bounded and observable. Rendering remote resources can make conversions dependent on network latency and availability; caching or bundling stable assets may reduce that variability where appropriate.

Troubleshoot common conversion failures

Symptom Likely cause What to check
WeasyPrint fails during installation or import. Required native dependencies are missing or incompatible. Verify the Python version and install the documented Pango and platform dependencies for the environment.
An image or stylesheet is missing. The resource URL cannot be resolved, retrieved, or authorized. Check base URLs, relative paths, network access, redirects, and fetcher policy; verify protected resources have an intentional authentication method.
The PDF is generated but layout differs from a browser. The converter’s CSS support or layout engine differs from the browser used to preview the page. Reduce the document to a failing fixture and confirm support for the CSS features in use; test the alternative renderer against the same input.
xhtml2pdf reports errors or omits content. Markup, CSS, resource access, or backend configuration may be unsupported or invalid. Inspect the returned status and conversion diagnostics, confirm the recommended rendering backend, and validate the specific feature against project documentation.
wkhtmltopdf cannot be launched. The binary is absent, incompatible with the host, or not on PATH. Install the appropriate official binary and configure an explicit executable path where needed.
A conversion hangs or consumes excessive resources. A slow or unbounded resource request, complex input, or runaway workload can hold the renderer open. Set application-level time and resource limits, restrict resource fetching, and test the problematic input in isolation.
A PDF is incomplete despite a successful process exit. Some resources may have failed without aborting the whole conversion. Inspect the PDF itself and log resource and renderer diagnostics; use a fixture-based validation step for important output.

Or skip the browser setup

If the task is to capture a live web page as an image or PDF—not to build a PDF from a custom HTML template—ScreenshotNeo is a website screenshot API and MCP server. A single GET request can return a PNG, JPEG, WebP, or PDF. For example, save a PDF response like this:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key=YOUR_API_KEY 
  --data-urlencode url=https://stripe.com 
  -d format=pdf 
  -o page.pdf

See the ScreenshotNeo API documentation for request parameters. ScreenshotNeo accepts cookie or consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of these steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots.

Sign up for 1,000 free screenshots a month—no card required.

Frequently Asked Questions

Can WeasyPrint convert a PDF from an HTML string without creating an HTML file?

Yes. Pass the string to HTML(string=...) and call write_pdf() with an output destination.

Which option should I test first for modern print CSS?

WeasyPrint is the first candidate to evaluate for new print-oriented documents and paged-media layouts.

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

Is wkhtmltopdf safe for user-submitted HTML?

The project warns against using it with untrusted HTML. Do not send user-controlled HTML or JavaScript directly to it.

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.