{"schemaVersion":"1.0","record":{"label":"xhtml2pdf","description":"Python HTML-to-PDF converter built on ReportLab with page templates, frames and resource-access policies.","aliases":["pisa"],"kind":"software","website":"https://xhtml2pdf.readthedocs.io/","overview":"xhtml2pdf converts HTML and supported CSS into PDFs using Python and the ReportLab toolkit, with pypdf among its dependencies. It provides a Python interface and command-line entry points for template-driven document generation. Its page-and-frame model and renderer-specific controls mean that browser layout compatibility must be assessed rather than assumed.","license":"Apache-2.0","lifecycle":"active","example":false,"features":[{"name":"Page templates and frames","status":"supported","detail":"Content flows through rectangular content frames; static frames provide recurring content.","useCase":"Python HTML-template PDF generation","platforms":["Python 3.10+; dependencies vary by platform"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://xhtml2pdf.readthedocs.io/en/latest/format_html.html","locator":"Content/static frames and unsupported CSS page property","retrievedAt":"2026-10-07T12:42:28.193Z","kind":"vendor"}]},{"name":"Interactive form controls","status":"limited","detail":"Supported named controls become PDF fields; radio inputs are drawn without an interactive radio group.","useCase":"Python HTML-template PDF generation","platforms":["Python 3.10+; dependencies vary by platform"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://xhtml2pdf.readthedocs.io/en/latest/reference.html","locator":"Tables, long-cell handling and PDF form limitations","retrievedAt":"2026-10-07T12:42:28.193Z","kind":"vendor"}]},{"name":"Denied-resource handling","status":"limited","detail":"Denied assets are warned about and omitted while rendering continues; successful completion need not mean every asset loaded.","useCase":"Python HTML-template PDF generation","platforms":["Python 3.10+; dependencies vary by platform"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://xhtml2pdf.readthedocs.io/en/latest/security.html","locator":"Default resource policy, skipped denied assets and resource exhaustion","retrievedAt":"2026-10-07T12:42:28.193Z","kind":"vendor"}]}],"alternatives":[],"slug":"xhtml2pdf","draftAlternatives":[{"targetSlug":"weasyprint","status":"limited","detail":"Can cover compatible HTML-template PDF generation in Python, with different page-template syntax and layout limits.","useCase":"Python HTML-template PDF generation","platforms":["Python 3.10+; dependencies vary by platform"],"region":"Version, build and integration requirements apply","evidence":[{"url":"https://xhtml2pdf.readthedocs.io/en/latest/","locator":"HTML/CSS conversion, Python and CLI interfaces","retrievedAt":"2026-10-07T12:42:28.193Z","kind":"vendor"},{"url":"https://xhtml2pdf.readthedocs.io/en/latest/format_html.html","locator":"Content/static frames and unsupported CSS page property","retrievedAt":"2026-10-07T12:42:28.193Z","kind":"vendor"},{"url":"https://doc.courtbouillon.org/weasyprint/stable/","locator":"HTML/CSS pagination engine","retrievedAt":"2026-10-07T12:42:28.193Z","kind":"vendor"}]}],"evidence":[{"url":"https://xhtml2pdf.readthedocs.io/en/latest/","locator":"HTML/CSS conversion, Python and CLI interfaces","retrievedAt":"2026-10-07T12:42:28.193Z","kind":"vendor"},{"url":"https://xhtml2pdf.readthedocs.io/en/latest/format_html.html","locator":"Content/static frames and unsupported CSS page property","retrievedAt":"2026-10-07T12:42:28.193Z","kind":"vendor"},{"url":"https://github.com/xhtml2pdf/xhtml2pdf/blob/master/pyproject.toml","locator":"Python 3.10+, dependencies and command-line entry points","retrievedAt":"2026-10-07T12:42:28.193Z","kind":"vendor"},{"url":"https://xhtml2pdf.readthedocs.io/en/latest/security.html","locator":"What is refused by default; Choosing your own policy; On the command line; link_callback warning.","retrievedAt":"2026-10-07T12:42:28.193Z","kind":"vendor"}],"document":{"version":1,"references":[{"url":"https://xhtml2pdf.readthedocs.io/en/latest/","locator":"HTML/CSS conversion, Python and CLI interfaces","retrievedAt":"2026-10-07T12:42:28.193Z","id":"home","title":"xhtml2pdf documentation","kind":"vendor"},{"url":"https://xhtml2pdf.readthedocs.io/en/latest/format_html.html","locator":"Content/static frames and unsupported CSS page property","retrievedAt":"2026-10-07T12:42:28.193Z","id":"layout","title":"xhtml2pdf page layout","kind":"vendor"},{"url":"https://xhtml2pdf.readthedocs.io/en/latest/reference.html","locator":"Tables, long-cell handling and PDF form limitations","retrievedAt":"2026-10-07T12:42:28.193Z","id":"reference","title":"xhtml2pdf reference","kind":"vendor"},{"url":"https://xhtml2pdf.readthedocs.io/en/latest/security.html","locator":"Default resource policy, skipped denied assets and resource exhaustion","retrievedAt":"2026-10-07T12:42:28.193Z","id":"security","title":"xhtml2pdf resource security","kind":"vendor"},{"url":"https://github.com/xhtml2pdf/xhtml2pdf/blob/master/pyproject.toml","locator":"Python 3.10+, dependencies and command-line entry points","retrievedAt":"2026-10-07T12:42:28.193Z","id":"package","title":"xhtml2pdf package metadata","kind":"vendor"},{"url":"https://github.com/xhtml2pdf/xhtml2pdf/blob/master/LICENSE.txt","locator":"Apache License Version 2.0","retrievedAt":"2026-10-07T12:42:28.193Z","id":"license","title":"xhtml2pdf license","kind":"vendor"},{"url":"https://doc.courtbouillon.org/weasyprint/stable/","locator":"HTML/CSS pagination engine","retrievedAt":"2026-10-07T12:42:28.193Z","id":"weasy","title":"WeasyPrint documentation","kind":"vendor"}],"overviewCitations":["home","layout","package"],"licenseCitations":["license"],"sections":[{"id":"frames","heading":"Page templates and flowing content","paragraphs":[{"id":"frames-detail","content":[{"text":"A page template defines dimensions and orientation, while rectangular frames define where content is placed. Content frames carry flowing HTML across the document; static frames supply recurring items such as headers and footers. The manual explicitly says that a CSS page-name property used by other engines does not select templates here. xhtml2pdf uses its own template-switching mechanisms, making this a practical migration issue."}],"citations":["layout"]}]},{"id":"tables","heading":"Tables and form behavior","paragraphs":[{"id":"tables-detail","content":[{"text":"The reference recommends explicit table widths and documents constrained handling for cells taller than the available space. A configured policy may shrink, truncate, overflow or reject such content, so table output should be checked with long real data. The form interface also has limits: named supported controls become PDF fields, but radio inputs are merely drawn, and choice options cannot separate a stored value from their label."}],"citations":["reference"]}]},{"id":"resources","heading":"Resource access and incomplete output","paragraphs":[{"id":"resources-detail","content":[{"text":"Resource restrictions depend on the entry point. The Python rendering policy normally blocks internal network addresses and local files outside the permitted directory. For a named command-line document, network restrictions still apply, but local-file confinement requires --resource-root. A denied asset is logged and omitted while rendering continues, so inspect warnings and output for missing stylesheets, fonts and images. The link callback rewrites locations; the resource policy controls access. The documentation also recommends an explicit allowed-host policy for untrusted input because an address check alone does not close DNS-rebinding risks."}],"citations":["security"]}]},{"id":"deployment","heading":"Deployment limits and licensing","paragraphs":[{"id":"deployment-detail","content":[{"text":"The package requires Python 3.10 or later and includes ReportLab and other parsing, imaging and PDF dependencies. Apache-2.0 licensing applies to xhtml2pdf, while dependencies retain their own terms. Resource-access controls also do not bound conversion time or total memory use: the security guidance still calls for limits around untrusted work. This article reports those documented boundaries without claiming a tested secure deployment."}],"citations":["package","license","security"]}]},{"id":"comparison","heading":"Substitution considerations","paragraphs":[{"id":"comparison-detail","content":[{"text":"xhtml2pdf can substitute for "},{"text":"WeasyPrint","targetSlug":"weasyprint"},{"text":" when the required output is a PDF from compatible HTML templates. Both support Python workflows, but xhtml2pdf's frame model and renderer-specific controls can require template changes. Confirm recurring content, long tables and form behavior before switching; a shared HTML input format does not establish identical pagination or complete browser-CSS support."}],"citations":["home","layout","reference","weasy"]}]}]},"id":"Q1453","revision":1533,"updatedAt":"2026-10-19T11:06:04Z","sourceUrl":"https://substitutefor.net/entities/Q1453?revision=1533"}}