WeasyPrint HTML and CSS renderer for generating paginated PDF documents through Python or a command-line interface.
Overview WeasyPrint renders HTML and CSS into paginated PDF documents for applications such as reports, invoices and books. Its Python layout engine is designed for print-oriented web standards rather than a full interactive browser. It is available as open-source software with command-line and Python interfaces.[1] [2]
Contents Template-driven pagination Documents can be generated from HTML templates with CSS controlling their printed layout. The common-use guide places page size and margins in @page rules and describes page numbering and headers. This lets a web-oriented template produce discrete pages rather than merely capture a scrolling screen. The resulting pagination still depends on the renderer's supported CSS and the actual content supplied.[1] [3]
Static rendering and release changes WeasyPrint does not execute the JavaScript that an interactive website might use to populate its content. Required text and graphics must therefore be available through the input and supported resources. The API reference also warns that rendered output can change between releases even when calling code still works. Keeping templates compatible requires checking representative output, not only whether an upgrade completes without an API exception.[4] [5]
Resource access and untrusted input The default fetcher can read file and HTTP URLs, but does not automatically provide browser-style cookies or authentication. Applications may need a custom fetcher for controlled resources. The security guide warns that untrusted HTML or CSS can cause excessive processing and expose accessible files. Deployment should constrain resources, filesystem and network access rather than assume that generating a PDF is an inherently isolated operation.[2]
Specialized outputs The renderer exposes options for specialized PDF variants, including archival and accessibility-oriented outputs. Its documentation explicitly declines to guarantee conformance for arbitrary inputs: the HTML structure, styles and chosen PDF features must also satisfy the relevant requirements. Selecting a profile is therefore part of producing a compliant document, not a substitute for checking the finished output against the required specification.[3]
Distribution and substitution The BSD-3-Clause engine has documented Linux, macOS and Windows installation routes, with Python and Pango among its dependencies. It can substitute for Prince for suitable HTML/CSS document-generation workloads. A switch requires validating pagination and fonts and replacing any unsupported scripting or engine-specific styles. This comparison establishes a shared production task, without claiming identical typesetting or a measured performance advantage.[1] [2] [4] [5] [6]
Also included: 3 capabilities and 0 substitute relationships. Check substitutes in section 1 and capabilities in section 3.