Render an HTML file to PDF

$ weasyprint [path/to/input.html] [path/to/output].pdf

Render an HTML file to PNG, including an additional user stylesheet

$ weasyprint [path/to/input.html] [path/to/output].png --stylesheet [path/to/stylesheet.css]

Output additional debugging information when rendering

$ weasyprint [path/to/input.html] [path/to/output].pdf --verbose

Specify a custom resolution when outputting to PNG

$ weasyprint [path/to/input.html] [path/to/output].png --resolution [300]

Specify a base URL for relative URLs in the input HTML file

$ weasyprint [path/to/input.html] [path/to/output].png --base-url [url_or_filename]




WeasyPrint is a smart solution helping web developers to create PDF documents. It turns simple HTML pages into gorgeous statistical reports, invoices, tickets, etc.

From a technical point of view, WeasyPrint is a visual rendering engine for HTML and CSS that can export to PDF and PNG. It aims to support web standards for printing. WeasyPrint is free software made available under a BSD license.

It is based on various libraries but *not* on a full rendering engine like WebKit or Gecko. The CSS layout engine is written in Python, designed for pagination, and meant to be easy to hack on.


usage: weasyprint [-h] [--version] [-e ENCODING] [-f {pdf,png}] [-s STYLESHEET] [-m MEDIA_TYPE] [-r RESOLUTION] [-u BASE_URL] [-a ATTACHMENT] [-p] [-v] [-d] [-q] input output

Renders web pages to PDF or PNG.

positional arguments: input URL or filename of the HTML input, or - for stdin output Filename where output is written, or - for stdout

optional arguments: -h, --help show this help message and exit --version Print WeasyPrint's version number and exit. -e ENCODING, --encoding ENCODING Character encoding of the input -f {pdf,png}, --format {pdf,png} Output format. Can be omitted if `output` ends with a .pdf or .png extension. -s STYLESHEET, --stylesheet STYLESHEET URL or filename for a user CSS stylesheet. May be given multiple times. -m MEDIA_TYPE, --media-type MEDIA_TYPE Media type to use for @media, defaults to print -r RESOLUTION, --resolution RESOLUTION PNG only: the resolution in pixel per CSS inch. Defaults to 96, one PNG pixel per CSS pixel. -u BASE_URL, --base-url BASE_URL Base for relative URLs in the HTML input. Defaults to the input's own filename or URL or the current directory for stdin. -a ATTACHMENT, --attachment ATTACHMENT URL or filename of a file to attach to the PDF document -p, --presentational-hints Follow HTML presentational hints. -v, --verbose Show warnings and information messages. -d, --debug Show debugging messages. -q, --quiet Hide logging messages.


This version of weasyprint was written by Simon Sapin and contributors.

This man-page was created by Scott Kitterman <scott@kitterman.com> and is licensed under the same terms as weasyprint.

Copied to clipboard