# xhtml2pdf/xhtml2pdf

A library for converting HTML into PDFs using ReportLab

Repository: https://github.com/xhtml2pdf/xhtml2pdf
Canonical: https://ross.abutalabs.com/products/xhtml2pdf
Homepage: https://xhtml2pdf.readthedocs.io/
Language: Python
License: Apache-2.0
License Family: permissive
Topics: html-pdf, html-pdf-converter, html-to-pdf, html-to-pdf-converter, pdf, pdf-converter, pdf-generation, pypdf, python, reportlab, reportlab-pdf
Last push: 2026-08-26T03:06:12+00:00

## Health v2 (maintenance only)
Score: 67/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 99, release rhythm 8, longevity 100
- inputs: {"age_days": 5588, "days_push": 7, "days_rel": 556, "gap_med": null, "n_releases_24m": 1}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 2387, forks 655 (observed 2026-08-28T04:06:42.720191+00:00)

## What it is
xhtml2pdf is a pure-Python library that converts HTML and CSS (HTML5, CSS 2.1, partial CSS 3) into PDF documents using ReportLab, html5lib, and pypdf. It lets developers with web skills generate PDF templates without learning new rendering technologies.

## Use cases
- convert html to pdf in python
- generate pdf invoices from html templates
- create pdf reports from web templates
- render html css to pdf server-side
- generate printable pdf documents from django or flask
- produce pdf files without learning reportlab

## When to choose
- you or your team already know HTML and CSS and want to author PDF templates quickly
- you need a pure-Python, platform-independent PDF generation solution
- you want a lightweight alternative to headless browsers for PDF rendering

## When to avoid
- you need full modern CSS 3 layout support (flexbox, grid) - consider WeasyPrint or a headless browser
- you need pixel-perfect rendering of complex JavaScript-driven pages
- you require very high-fidelity print typography

## Facets
- artifact type: library
- maturity: active
- function: pdf, templating
- domain: pdf, web-development, files, developer-tools
- platform: python, cross-platform
- tags: html-to-pdf, reportlab, css, document-generation, pure-python, html

## Member repositories
- xhtml2pdf/xhtml2pdf (main) score 67

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:06:42.720191+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T02:34:35.496602+00:00, confidence not recorded.
  - readme: https://github.com/xhtml2pdf/xhtml2pdf (fetched 2026-08-28T04:06:42.720191+00:00, sha f96f3a0594ad)
  - registry_pypi: https://pypi.org/pypi/xhtml2pdf/json (fetched 2026-08-29T10:15:50.945366+00:00, sha 67a3549fbba0)
- Data as of 2026-08-30T08:39:29.467469+00:00.
