--- id: xhtml2pdf version: "0.2.17" license: Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for… (full text in the JSON record) license_treatment: permissive maintenance: aging --- # xhtml2pdf — PDF generator using HTML and CSS License: permissive · Maintenance: aging · Downloads: 4.3M/mo ## 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 above — verify before relying. Converts HTML and CSS to PDF documents using Python, enabling developers with web skills to generate PDF templates without learning specialized PDF libraries. 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 pip install xhtml2pdf uv add xhtml2pdf poetry add xhtml2pdf ## Installing xhtml2pdf 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. 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 = '