WeasyPrint is a Python library that converts HTML and CSS into PDF documents.
WeasyPrint solves the problem of generating formatted PDF reports, invoices, and tickets from web content. Rather than embedding a full browser rendering engine, it implements its own CSS layout engine written in Python and specifically designed for pagination. This approach allows developers to style documents using standard HTML and CSS while maintaining fine control over the output for print media.
The tool suits projects where you need to generate PDFs programmatically from HTML templates, particularly when you want to avoid the overhead and complexity of headless browser solutions. It works well for server-side document generation in Python applications. Choose WeasyPrint if you need a lightweight, hackable solution where the layout engine itself is accessible and modifiable. It requires Python 3.10 or later and runs on both CPython and PyPy.
Development on the tool is active and sustained. The project maintains comprehensive documentation and provides multiple examples demonstrating real-world usage. Professional support and maintenance are available through an associated organization, ensuring the project receives dedicated attention beyond community contributions. The codebase remains open to contributions under a clear licensing model that does not require copyright assignment from contributors.