What it does
xhtml2pdf renders HTML and CSS to PDF using Python and ReportLab. It provides a command-line tool and supports page templates, repeating table headers, document outlines, and form features.
Render an HTML string or file to a named PDF, then check the returned error result. Page templates, header/footer frames and repeating table rows control document layout without a browser process. Python 3.10 or later is documented; signing and vector rasterisation have separate dependencies. For server-rendered input, configure permitted asset hosts and directories explicitly. The resource-policy guide warns that a blocked resource can be omitted while the PDF still renders, so successful file creation alone does not establish that all content appeared.
Strengths
- Provides a standalone CLI and programmable PDF rendering from HTML.
Watch out for
- Signing and vector rasterisation need optional dependencies; missing or policy-blocked assets can leave an otherwise generated PDF incomplete.
Best for
- Python-based PDF generation from controlled HTML templates