WeasyPrint is a Python visual rendering engine that turns HTML and CSS into PDF, ideal for producing reports, invoices, and tickets, with a CSS layout engine designed for pagination and no browser engine dependency.
- v70.0
- Published at
- Sep 8, 2026
- 9,709
- Stars
- 28,698
- Download
- Synced at
- 8d ago
Latest release
v70.0Sep 8, 2026, 12:31 PMDownloads slow? Switch the source anytime above
README
Project Overview
WeasyPrint calls itself the awesome document factory, helping web developers turn simple HTML pages into gorgeous statistical reports, invoices, and tickets as PDF. Technically it is a visual rendering engine for HTML and CSS that exports to PDF, aiming to support web standards for printing; its CSS layout engine is written in Python, designed for pagination, and depends on no full engine like WebKit or Gecko.
| Item | Value |
|---|---|
| Platforms | Linux, macOS, Windows |
| Language | Python 3.11+ |
| License | BSD 3-Clause |
| Output format |
If you can write HTML and CSS, you can produce beautifully typeset PDFs.
Key Features
- HTML to PDF: hand it a URL or HTML file and get a paginated PDF
- CSS pagination engine: the layout engine is built for print pagination, with headers, footers, and page numbers
- Print standard support: implements print-oriented CSS features such as @page rules
- Font handling: web fonts and system fonts can be used and embedded
- Python API: generate PDFs on the server with a single call
- Standalone core: no browser engine dependency, light to deploy and easy to extend
Target Audience
- Backend developers generating reports and invoices
- Ops teams archiving web content as PDF
- Developers of publishing and ticket-printing systems
- Web engineers who want to reuse their CSS layout skills
Quick Start
- Install
pip install weasyprint- Render a PDF in Python
from weasyprint import HTML
HTML('report.html').write_pdf('report.pdf')- Or convert directly from the command line
weasyprint report.html report.pdfCore Advantages
- Reuse web skills: layout is expressed in plain HTML and CSS, no new template language to learn
- Born for pagination: page numbers and page-break control are supported natively
- No browser dependency: a pure Python layout engine keeps server deployment light
System Requirements
| Item | Requirement |
|---|---|
| Language | Python 3.11+, CPython and PyPy tested |
| OS | Linux, macOS, Windows |
| System deps | Pango and related graphics libraries |
Notes
- Not a browser: JavaScript is not executed, dynamic content must be rendered to static HTML first
- System libraries: install Pango on Linux servers first, missing libs cause startup errors
Release history
Sort