Updated Sep 21, 2026

Utilities

Turn styled HTML into paginated PDF output

weasyprint is a visual rendering engine for HTML and CSS that turns simple web pages into PDF documents, built to help developers generate reports, invoices, and tickets straight from HTML content.

installpip install weasyprint

Python · BSD-3-Clause license

Agent

overview

What weasyprint does

WeasyPrint loads one connected HTML document, applies its embedded styles and an optional --stylesheet file, then writes a PDF artifact. CSS print rules control page size, margins, breaks, headers, and other paged-media behavior.

Enable --presentational-hints when legacy HTML attributes such as width, align, or bgcolor should influence rendering. Modern documents should express those choices in CSS instead.

This is an HTML/CSS renderer, not a browser automation node. It does not execute application interactions or wait for client-side JavaScript to populate a page.

source github.com/Kozea/WeasyPrint

use cases

Where weasyprint fits

Render workflow reports

Turn generated HTML findings into a fixed PDF deliverable.

Create evidence bundles

Apply a shared print stylesheet to consistent review and audit documents.

Generate invoices or summaries

Render structured HTML records with CSS page headers, footers, and page breaks.

reference

weasyprint inputs and flags

3 inputs
NameTypeFlagDescription
inputFILE--inputInput HTML document.
stylesheetFILE--stylesheetAdditional CSS stylesheet.
presentational-hintsBOOLEAN--presentational-hintsHonor HTML presentational attributes.

Showing key inputs. weasyprint exposes 3 inputs in total.

example

Run weasyprint

weasyprint · command
weasyprint report.html report.pdf
sample output
%PDF-1.7
1 0 obj
<</Type /Pages/Count 1>>

guidance

Choosing weasyprint

Use WeasyPrint when HTML and CSS are the source of truth for a PDF. Use LibreOffice for office-document conversion.

libreoffice

Converts office documents through LibreOffice import and export filters.

pandoc

Converts document structure between markup and text-oriented formats.

browser-fetch

Renders JavaScript-driven web pages and captures browser output.

faq

weasyprint questions

No. Prepare complete HTML before connecting it to this node.

Yes. Connect a CSS file to --stylesheet.

Use CSS paged-media rules such as @page to set size and margins.

It lets older HTML presentation attributes affect the rendered result.

Run weasyprint yourself

A styled HTML fixture is rendered to one PDF page and checked for a valid PDF signature.

Facts on this page come from the live Trickest tool library.