$npx skillfedfor your agent

xhtml2pdf

PDF generator using HTML and CSS

With conditionsPyPI UtilitiesReleased Feb 20254.3M downloads / mopermissive licensePure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — xhtml2pdf-0.2.17-py3-none-any.whl
v0.2.17 · released 2025-02-23 · Python >=3.8 · 9 runtime deps: arabic-reshaper, html5lib, Pillow, pyHanko, pyhanko-certvalidator, pypdf, python-bidi, reportlab

Yes, if you need to convert HTML/CSS to PDF and want to avoid learning a specialized PDF library. The permissive Apache 2.0 license and low install friction make it accessible. However, the aging maintenance status (last release 537 days ago) warrants caution in production: verify that its rendering quality and feature set meet your specific layout and CSS requirements before committing to it as a core dependency. No known security vulnerabilities as of the fact sheet date.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires Python 3.8+.
  • For bitmap and vector rendering, reportlab needs a system-level graphics backend; cairo (installed via OS package manager) is recommended, or legacy RenderPM can be used as an alternative.
  • Low friction install with a pure-Python wheel.

License · maintenance · safety

permissive license (permissive) — Licensed under Apache License 2.0 (permissive). You may use, modify, and distribute xhtml2pdf and derivative works freely, provided you include a copy of the license and document any changes. No restrictions on commercial use.

last release 2025-02-23 (537 days) · last repo commit 2026-01-19 · 2,389 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 4,345,363 downloads/mo, #2,326 on PyPI

Verify before relying

pip install xhtml2pdf

from xhtml2pdf import pisa
from io import BytesIO

html_string = '<html><body><h1>Hello</h1></body></html>'
pdf_file = BytesIO()
pisa.CreatePDF(html_string, pdf_file)
pdf_file.seek(0)
  • Whether the aging maintenance status (537 days since release) affects stability or security in production use cases.
  • How well CSS 3 features beyond CSS 2.1 are actually supported in practice.
  • Performance characteristics when rendering large or complex HTML documents.
Same gist for agents: .md · .json

What it is and what it does

xhtml2pdf is a pure-Python HTML-to-PDF converter that wraps reportlab, html5lib, and pypdf to turn HTML5 and CSS 2.1 markup into PDF documents. It lets developers who know HTML and CSS generate PDF templates without learning a specialized PDF library or adopting a different technology stack. The tool is platform-independent and installs as a standard Python package.

The package handles the full pipeline: parsing HTML5 with html5lib, applying CSS styling, rendering text and images via reportlab (which requires a system graphics backend like cairo), and assembling the final PDF. It also integrates pyHanko for PDF signing, python-bidi for right-to-left text, arabic-reshaper for Arabic script support, and svglib for SVG embedding, making it suitable for multilingual and complex document layouts.

Use it for

  • Generate invoice or receipt PDFs from web templates without duplicating design logic between HTML and PDF systems.
  • Build report generators that accept HTML input and produce downloadable PDF files for distribution.
  • Create multilingual PDF documents with proper text directionality and script handling for Arabic and bidirectional content.
  • Embed SVG graphics and images in PDF output while maintaining CSS styling from the source HTML.
  • Automate PDF certificate or document generation in web applications by reusing existing HTML/CSS templates.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

With conditions

Yes, if you need to convert HTML/CSS to PDF and want to avoid learning a specialized PDF library.

The permissive Apache 2.0 license and low install friction make it accessible. However, the aging maintenance status (last release 537 days ago) warrants caution in production: verify that its rendering quality and feature set meet your specific layout and CSS requirements before committing to it as a core dependency. No known security vulnerabilities as of the fact sheet date.

Install

xhtml2pdf on PyPI

Before you install

Low friction install with a pure-Python wheel. Maintenance is aging—last release was 537 days ago and the last commit was 2026-01-19—but the repository remains active and not archived. The project carries 9 runtime dependencies including reportlab, html5lib, and pypdf, which are themselves mature libraries.

Requires Python 3.8+. For bitmap and vector rendering, reportlab needs a system-level graphics backend; cairo (installed via OS package manager) is recommended, or legacy RenderPM can be used as an alternative.

License in practice

Licensed under Apache License 2.0 (permissive). You may use, modify, and distribute xhtml2pdf and derivative works freely, provided you include a copy of the license and document any changes. No restrictions on commercial use.

Quickstart

pip install xhtml2pdf

from xhtml2pdf import pisa
from io import BytesIO

html_string = '<html><body><h1>Hello</h1></body></html>'
pdf_file = BytesIO()
pisa.CreatePDF(html_string, pdf_file)
pdf_file.seek(0)

Verify before relying

  • Whether the aging maintenance status (537 days since release) affects stability or security in production use cases.
  • How well CSS 3 features beyond CSS 2.1 are actually supported in practice.
  • Performance characteristics when rendering large or complex HTML documents.

Package facts

Licensepermissive license permissive
Python supportSupports the current Python release >=3.8
Install frictionLow. Pure-Python wheel
Runtime dependencies
9 packages
arabic-reshaperhtml5libPillowpyHankopyhanko-certvalidatorpypdfpython-bidireportlabsvglib
MaintenanceAging 537 days since the last release
Last repo commit
First released
Downloads4,345,363 / month, #2,326 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 4 - BetaEnvironment :: ConsoleEnvironment :: Other EnvironmentIntended Audience :: DevelopersIntended Audience :: System AdministratorsLicense :: OSI Approved :: Apache Software LicenseNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: DocumentationTopic :: MultimediaTopic :: Office/BusinessTopic :: PrintingTopic :: Text ProcessingTopic :: Text Processing :: FiltersTopic :: Text Processing :: FontsTopic :: Text Processing :: GeneralTopic :: Text Processing :: IndexingTopic :: Text Processing :: MarkupTopic :: Text Processing :: Markup :: HTMLTopic :: Text Processing :: Markup :: XMLTopic :: Utilities

Evidence: xhtml2pdf-0.2.17-py3-none-any.whl

Tags

Capabilities
html to pdf conversiongenerate pdf from htmlcss to pdf renderingpython pdf generatorhtml css pdf exportweb template to pdfreportlab html wrapper
Topics
pdf-generationhtml-renderingdocument-automation
PyPI keywords
PDFHTMLHTMLXMLCSS

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “generate pdf from html”

  • xhtml2pdfConverts HTML and CSS to PDF documents using Python, enabling…
  • django-wkhtmltopdfWraps the wkhtmltopdf binary to convert HTML to PDF within Django…
  • pdfkitPython wrapper for wkhtmltopdf that converts HTML to PDF using the…

Give your agent the search over MCP, or paste the wish link into any chat.

More Utilities packages

idna Worth it
PyPI · Python Modules · released Jun 2026

Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.

Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.

BSD-3-Clausepure Python · 3.9+
1.8Bdownloads / mo
charset-normalizer Worth it
PyPI · Utilities · released Aug 2026

Detects and normalizes text encoding from unknown or ambiguous sources, supporting all IANA character sets that Python's core library provides codecs for, with the ability to register custom codecs.

permissive licensepure Python · 3.7+
1.7Bdownloads / mo
setuptools Worth it
PyPI · Python Modules · released Aug 2026

Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.

MITpure Python · 3.10+
1.6Bdownloads / mo
pluggy Worth it
PyPI · Libraries · released May 2025

Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.

Install it if you're building an extensible application or framework.

MITpure Python · 3.9+aging
1.3Bdownloads / mo
Pygments Worth it
PyPI · Utilities · released Mar 2026

Pygments is a syntax highlighter that colorizes source code and text in over 500 languages and formats, outputting to HTML, LaTeX, RTF, SVG, images, or ANSI terminal sequences.

Install it if you need to display or transform source code.

BSD-2-Clausepure Python · 3.9+
1.3Bdownloads / mo
six With conditions
PyPI · Libraries · released Dec 2024

Six provides utility functions to write Python code that runs on both Python 2.7 and Python 3.3+, smoothing over language differences between the two versions.

MITpure Python
1.2Bdownloads / mo

See also weasyprint · md2pdf · pdfkit · rst2pdf · markdown-pdf · django-weasyprint · pyth3 · pynliner · pdfrw2 · svglib