# WeasyPrint

HTML and CSS renderer for generating paginated PDF documents through Python or a command\-line interface\.

ID: Q411 · Revision: 397

Type: software · License: BSD\-3\-Clause[^intro] · Status: active

Website: https://weasyprint.org/



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\.[^intro][^steps]

## 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\.[^cases][^intro]

## 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\.[^scope][^api]

## 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\.[^steps]

## 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\.[^cases]

## 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](/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\.[^intro][^steps][^api][^scope][^prince]

## Capabilities and substitutions

### CSS pagination — supported

Page dimensions and margins are specified through CSS @page rules\.[^cases]

Use case: Generating paginated PDFs from HTML and CSS · Platforms: Linux, macOS, Windows · Region: Version, build and integration requirements apply

### Client\-side JavaScript rendering — unsupported

The engine's documented scope excludes JavaScript and interactive browser behavior\.[^scope]

Use case: Generating paginated PDFs from HTML and CSS · Platforms: Linux, macOS, Windows · Region: Version, build and integration requirements apply

### PDF/A and PDF/UA output — limited

Variant options exist, but conformance depends on document content and is not guaranteed\.[^cases]

Use case: Generating paginated PDFs from HTML and CSS · Platforms: Linux, macOS, Windows · Region: Version, build and integration requirements apply

### [Substitute for Prince](/prince) — limited

Can cover HTML/CSS\-to\-PDF generation; engine\-specific layouts and scripting requirements need separate checks\.[^intro][^scope][^prince]

Use case: Generating paginated PDFs from HTML and CSS · Platforms: Linux, macOS, Windows · Region: Version, build and integration requirements apply

## References

[^intro]: [WeasyPrint documentation](<https://doc.courtbouillon.org/weasyprint/stable/>) — HTML/CSS pagination engine and BSD\-3\-Clause licensing (vendor; retrieved 2026-10-07T12:36:26.169Z)

[^steps]: [WeasyPrint first steps](<https://doc.courtbouillon.org/weasyprint/stable/first_steps.html>) — Platform dependencies, URL fetchers and untrusted\-input risks (vendor; retrieved 2026-10-07T12:36:26.169Z)

[^cases]: [WeasyPrint common use cases](<https://doc.courtbouillon.org/weasyprint/stable/common_use_cases.html>) — Page dimensions, PDF variants and conformance caveat (vendor; retrieved 2026-10-07T12:36:26.169Z)

[^api]: [WeasyPrint API reference](<https://doc.courtbouillon.org/weasyprint/stable/api_reference.html>) — Versioning and rendering changes (vendor; retrieved 2026-10-07T12:36:26.169Z)

[^scope]: [WeasyPrint design scope](<https://doc.courtbouillon.org/weasyprint/stable/going_further.html>) — Static paged content without JavaScript execution (vendor; retrieved 2026-10-07T12:36:26.169Z)

[^prince]: [Prince overview](<https://www.princexml.com/>) — HTML/CSS PDF generation and paged layout (vendor; retrieved 2026-10-07T12:36:26.169Z)

Source revision: https://substitutefor.net/entities/Q411?revision=397
