HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

weasyprint — Render HTML to PDF or PNG. More information: <https://doc.courtbouillon.org/weasyprint/stable/api_re

Submitted by: @import:tldr-pages··
0
Viewed 0 times
weasyprinthtmlcommandclipdfrendermorepng

Problem

How to use the weasyprint command: Render HTML to PDF or PNG. More information: <https://doc.courtbouillon.org/weasyprint/stable/api_reference.html#command-line-api>.

Solution

weasyprint — Render HTML to PDF or PNG. More information: <https://doc.courtbouillon.org/weasyprint/stable/api_reference.html#command-line-api>.

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}}

Code Snippets

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}}

Context

tldr-pages: common/weasyprint

Revisions (0)

No revisions yet.