Description
- weasyprint.__main__.main(argv=sys.argv)
The
weasyprint
program takes at least two arguments:weasyprint [options] <input> <output>
The input is a filename or URL to an HTML document, or
-
to read HTML from stdin. The output is a filename, or-
to write to stdout.Options can be mixed anywhere before, between, or after the input and output.
- -e <input_encoding>, --encoding <input_encoding>
Force the input character encoding (e.g.
-e utf-8
).
- -s <filename_or_URL>, --stylesheet <filename_or_URL>
Filename or URL of a user cascading stylesheet (see Stylesheet Origins) to add to the document (e.g.
-s print.css
). Multiple stylesheets are allowed.
- -m <type>, --media-type <type>
Set the media type to use for
@media
. Defaults toprint
.
- -u <URL>, --base-url <URL>
Set the base for relative URLs in the HTML input. Defaults to the input’s own URL, or the current directory for stdin.
- -a <file>, --attachment <file>
Adds an attachment to the document. The attachment is included in the PDF output. This option can be used multiple times.
- --pdf-identifier <identifier>
PDF file identifier, used to check whether two different files are two different versions of the same original document.
- --pdf-variant <variant-name>
PDF variant to generate (e.g.
--pdf-variant pdf/a-3b
).
- --pdf-version <version-number>
PDF version number (default is 1.7).
- --custom-metadata
Include custom HTML meta tags in PDF metadata.
- -p, --presentational-hints
Follow HTML presentational hints.
- -O <type>, --optimize-size <type>
Optimize the size of generated documents. Supported types are
images
,fonts
,all
andnone
. This option can be used multiple times,all
adds all allowed values,none
removes all previously set values.
- -v, --verbose
Show warnings and information messages.
- -d, --debug
Show debugging messages.
- -q, --quiet
Hide logging messages.
- --version
Show the version number. Other options and arguments are ignored.
- -h, --help
Show the command-line usage. Other options and arguments are ignored.
About
The Awesome Document Factory
WeasyPrint is a smart solution helping web developers to create PDF documents. It turns simple HTML pages into gorgeous statistical reports, invoices, tickets…
From a technical point of view, WeasyPrint is a visual rendering engine for HTML and CSS that can export to PDF. 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.
Free software: BSD license
For Python 3.7+, tested on CPython and PyPy
Documentation: https://doc.courtbouillon.org/weasyprint
Examples: https://weasyprint.org/samples/
Changelog: https://github.com/Kozea/WeasyPrint/releases
Code, issues, tests: https://github.com/Kozea/WeasyPrint
Code of conduct: https://www.courtbouillon.org/code-of-conduct
Professional support: https://www.courtbouillon.org
Donation: https://opencollective.com/courtbouillon
WeasyPrint has been created and developed by Kozea (https://kozea.fr/). Professional support, maintenance and community management is provided by CourtBouillon (https://www.courtbouillon.org/).
Copyrights are retained by their contributors, no copyright assignment is required to contribute to WeasyPrint. Unless explicitly stated otherwise, any contribution intentionally submitted for inclusion is licensed under the BSD 3-clause license, without any additional terms or conditions. For full authorship information, see the version control history.