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

wkhtmltopdf — Convert HTML documents or web pages into PDF files. More information: <https://wkhtmltopdf.org/usage

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

Problem

How to use the wkhtmltopdf command: Convert HTML documents or web pages into PDF files. More information: <https://wkhtmltopdf.org/usage/wkhtmltopdf.txt>.

Solution

wkhtmltopdf — Convert HTML documents or web pages into PDF files. More information: <https://wkhtmltopdf.org/usage/wkhtmltopdf.txt>.

Convert a HTML document into PDF:
wkhtmltopdf {{input.html}} {{output.pdf}}


Specify the PDF page size (please see PaperSize of QPrinter for supported sizes):
wkhtmltopdf --page-size {{A4}} {{input.html}} {{output.pdf}}


Set the PDF page margins:
wkhtmltopdf --margin-{{top|bottom|left|right}} {{10mm}} {{input.html}} {{output.pdf}}


Set the PDF page orientation:
wkhtmltopdf --orientation {{Landscape|Portrait}} {{input.html}} {{output.pdf}}


Generate a greyscale version of the PDF document:
wkhtmltopdf --grayscale {{input.html}} {{output.pdf}}

Code Snippets

Convert a HTML document into PDF

wkhtmltopdf {{input.html}} {{output.pdf}}

Specify the PDF page size (please see `PaperSize` of `QPrinter` for supported sizes)

wkhtmltopdf --page-size {{A4}} {{input.html}} {{output.pdf}}

Set the PDF page margins

wkhtmltopdf --margin-{{top|bottom|left|right}} {{10mm}} {{input.html}} {{output.pdf}}

Set the PDF page orientation

wkhtmltopdf --orientation {{Landscape|Portrait}} {{input.html}} {{output.pdf}}

Generate a greyscale version of the PDF document

wkhtmltopdf --grayscale {{input.html}} {{output.pdf}}

Context

tldr-pages: common/wkhtmltopdf

Revisions (0)

No revisions yet.