WKHTMLTOPDF(1)

πŸ“¦
version 0.12.6 Β· 2 versions
, in debian bookworm, fedora 43, fedora 44, ubuntu jammy, ubuntu noble

WKHTMLTOPDF(1) πŸ’–

okay bestie, so this is the General Commands Manual page for wkhtmltopdf β€” yes, the little html-to-pdf converter that could. grab a boba, we're going in πŸ§‹βœ¨


NAME πŸŽ€

wkhtmltopdf β€” html to pdf converter. that's it. that's the whole name section. iconic brevity honestly πŸ’…


SYNOPSIS ✨

wkhtmltopdf [GLOBAL OPTION]... [OBJECT]... <output file>

like, give it your global options, give it your objects, tell it where the output file goes, and it will serve. periodt.


DOCUMENT OBJECTS πŸ¦‹

so here's the tea: wkhtmltopdf can put several objects into the output file. an object is either:

  • a single webpage 🌐
  • a cover webpage πŸ“”
  • a table of contents πŸ“‘

they land in the output document in the order you specify them on the command line. options can be set per object or in the global options area. but heads up β€” options from the Global Options section can only live in the global options area, no exceptions bestie.

A page object 🌸

puts the content of a single webpage into the output document.

(page)? <input url/file name> [PAGE OPTION]...

options for the page object can go in the global options area and the page options area. which ones apply? check the Page Options and Headers And Footer Options sections, babes.

A cover object πŸ“”

also puts the content of a single webpage into the output document, but the page does not appear in the table of contents, and it has no headers and footers. it's the mysterious one. main character who doesn't show up in the credits.

cover <input url/file name> [PAGE OPTION]...

every option you can set for a page object? you can set it for a cover too. slay.

A table of contents object πŸ“‘

inserts a table of contents into the output document.

toc [TOC OPTION]...

all the page-object options work here too, plus the extra ones from the TOC Options section. and the table of contents is generated via XSLT, which means you can style it to look however you want it to look. literally whatever vibe you're going for. 🎨

to get an idea of how to do this, you can dump the default xslt document by supplying --dump-default-toc-xsl, and the outline it works on by supplying --dump-outline β€” see the Outline Options section. iykyk πŸ’…


DESCRIPTION πŸ’–

Converts one or more HTML pages into a PDF document, not using wkhtmltopdf patched qt. (remember that. it matters later, fr fr.)


GLOBAL OPTIONS ✨

these are the big-picture ones, bestie. they go in the global options area only!

  • --collate β€” Collate when printing multiple copies
  • --no-collate β€” Do not collate when printing multiple copies
  • --cookie-jar <path> β€” Read and write cookies from and to the supplied cookie jar file
  • --copies <number> β€” Number of copies to print into the pdf file
  • -d, --dpi <dpi> β€” Change the dpi explicitly (this has no effect on X11 based systems)
  • -H, --extended-help β€” Display more extensive help, detailing less common command switches
  • -g, --grayscale β€” PDF will be generated in grayscale
  • -h, --help β€” Display help
  • --htmldoc β€” Output program html help
  • --license β€” Output license information and exit
  • --log-level <level> β€” Set log level to: none, error, warn or info
  • -l, --lowquality β€” Generates lower quality pdf/ps. Useful to shrink the result document space
  • --manpage β€” Output program man page
  • -B, --margin-bottom <unitreal> β€” Set the page bottom margin
  • -L, --margin-left <unitreal> β€” Set the page left margin
  • -R, --margin-right <unitreal> β€” Set the page right margin
  • -T, --margin-top <unitreal> β€” Set the page top margin
  • -O, --orientation <orientation> β€” Set orientation to Landscape or Portrait
  • --page-height <unitreal> β€” Page height
  • -s, --page-size <Size> β€” Set paper size to: A4, Letter, etc.
  • --page-width <unitreal> β€” Page width
  • -q, --quiet β€” Be less verbose, maintained for backwards compatibility; Same as using --log-level none
  • --read-args-from-stdin β€” Read command line arguments from stdin
  • --readme β€” Output program readme
  • --title <text> β€” The title of the generated pdf file (The title of the first document is used if not specified)
  • -V, --version β€” Output version information and exit

PAGE OPTIONS πŸ¦‹

these can live in the global options area or the page options area. flexible queens only. πŸ‘‘

  • --allow <path> β€” Allow the file or files from the specified folder to be loaded (repeatable)
  • --background β€” Do print background
  • --no-background β€” Do not print background
  • --bypass-proxy-for <value> β€” Bypass proxy for host (repeatable)
  • --cache-dir <path> β€” Web cache directory
  • --checkbox-checked-svg <path> β€” Use this SVG file when rendering checked checkboxes
  • --checkbox-svg <path> β€” Use this SVG file when rendering unchecked checkboxes
  • --cookie <name> <value> β€” Set an additional cookie (repeatable), value should be url encoded.
  • --custom-header <name> <value> β€” Set an additional HTTP header (repeatable)
  • --custom-header-propagation β€” Add HTTP headers specified by --custom-header for each resource request.
  • --no-custom-header-propagation β€” Do not add HTTP headers specified by --custom-header for each resource request.
  • --debug-javascript β€” Show javascript debugging output
  • --no-debug-javascript β€” Do not show javascript debugging output
  • --encoding <encoding> β€” Set the default text encoding, for input
  • --images β€” Do load or print images
  • --no-images β€” Do not load or print images
  • -n, --disable-javascript β€” Do not allow web pages to run javascript
  • --enable-javascript β€” Do allow web pages to run javascript
  • --javascript-delay <msec> β€” Wait some milliseconds for javascript finish
  • --load-error-handling <handler> β€” Specify how to handle pages that fail to load: abort, ignore or skip
  • --load-media-error-handling <handler> β€” Specify how to handle media files that fail to load: abort, ignore or skip
  • --disable-local-file-access β€” Do not allowed conversion of a local file to read in other local files, unless explicitly allowed with --allow
  • --enable-local-file-access β€” Allowed conversion of a local file to read in other local files.
  • --minimum-font-size <int> β€” Minimum font size
  • --page-offset <offset> β€” Set the starting page number
  • --password <password> β€” HTTP Authentication password
  • --disable-plugins β€” Disable installed plugins
  • --enable-plugins β€” Enable installed plugins (plugins will likely not work)
  • --post <name> <value> β€” Add an additional post field (repeatable)
  • --post-file <name> <path> β€” Post an additional file (repeatable)
  • -p, --proxy <proxy> β€” Use a proxy
  • --proxy-hostname-lookup β€” Use the proxy for resolving hostnames
  • --radiobutton-checked-svg <path> β€” Use this SVG file when rendering checked radiobuttons
  • --radiobutton-svg <path> β€” Use this SVG file when rendering unchecked radiobuttons
  • --run-script <js> β€” Run this additional javascript after the page is done loading (repeatable)
  • --ssl-crt-path <path> β€” Path to the ssl client cert public key in OpenSSL PEM format, optionally followed by intermediate ca and trusted certs
  • --ssl-key-password <password> β€” Password to ssl client cert private key
  • --ssl-key-path <path> β€” Path to ssl client cert private key in OpenSSL PEM format
  • --stop-slow-scripts β€” Stop slow running javascripts
  • --no-stop-slow-scripts β€” Do not Stop slow running javascripts
  • --user-style-sheet <path> β€” Specify a user style sheet, to load with every page
  • --username <username> β€” HTTP Authentication username
  • --window-status <windowStatus> β€” Wait until window.status is equal to this string before rendering page
  • --zoom <float> β€” Use this zoom factor

SPECIFYING A PROXY πŸ’…

by default, proxy info gets read from the environment variables: proxy, all_proxy and http_proxy. you can also specify proxy options with the -p switch. ✨

<type> := "http://" | "socks5://"
<serif> := <username> (":" <password>)? "@"
<proxy> := "None" | <type>? <string>? <host> (":" <port>)?

here are some examples (in case you are unfamiliar with the BNF, bestie, no shame in it 🫢):

http://user:password@myproxyserver:8080
socks5://myproxyserver
None

REDUCED FUNCTIONALITY πŸ’€

okay this is the part where i hold your hand. 🫢 This version of wkhtmltopdf has been compiled against a version of QT without the wkhtmltopdf patches. therefore some features are missing β€” if you need these features please use the static version.

currently the list of features only supported with patch QT includes:

  • Printing more than one HTML document into a PDF file.
  • Running without an X11 server.
  • Adding a document outline to the PDF file.
  • Adding headers and footers to the PDF file.
  • Generating a table of contents.
  • Adding links in the generated PDF file.
  • Printing using the screen media-type.
  • Disabling the smart shrink feature of WebKit.
not me finding out half the fun stuff is missing 😭 check your build before you commit to the bit, fr fr.

PAGE SIZES 🌈

the default page size of the rendered document is A4, but by using the --page-size option this can be changed to almost anything else, such as: A3, Letter and Legal. for a full list of supported pages sizes please see <https://qt-project.org/doc/qt-4.8/qprinter.html#PaperSize-enum>.

for a more fine grained control over the page size, the --page-height and --page-width options may be used. ✨


READING ARGUMENTS FROM STDIN πŸ“

if you need to convert a lot of pages in a batch, and you feel that wkhtmltopdf is a bit too slow to start up, then you should try --read-args-from-stdin. this one's for the girlies doing bulk conversions. πŸ’…

when --read-args-from-stdin is on, each line of input sent to wkhtmltopdf on stdin will act as a separate invocation of wkhtmltopdf, with the arguments specified on the given line combined with the arguments given to wkhtmltopdf.

for example one could do the following:

echo "https://qt-project.org/doc/qt-4.8/qapplication.html
qapplication.pdf" >> cmds
echo "cover google.com https://en.wikipedia.org/wiki/Qt_(software)
qt.pdf" >> cmds
wkhtmltopdf --read-args-from-stdin --book < cmds

PAGE BREAKING βœ‚οΈ

the current page breaking algorithm of WebKit leaves much to be desired. basically WebKit will render everything into one long page, and then cut it up into pages. 😭

this means that if you have two columns of text where one is vertically shifted by half a line, then WebKit will cut a line into to pieces β€” display the top half on one page, and the bottom half on another page. it will also break image in two and so on. it's giving chaos, honestly. πŸ’€

if you are using the patched version of QT you can use the CSS page-break-inside property to remedy this somewhat. there is no easy solution to this problem β€” until this is solved, try organizing your HTML documents such that it contains many lines on which pages can be cut cleanly. ✨


πŸ’¬ CONTACT πŸ’¬

okay bestie, real talk: if you hit a bug πŸ› or you're like "hmm I wish this thing did X" and you want a shiny new feature, do not just sit there seething in your group chat. Go tell the devs! πŸ’–

Head on over to https://wkhtmltopdf.org/support.html and spill the tea. They wanna hear it, fr fr. 🫢


πŸ‘‘ AUTHORS πŸ‘‘

this is the iconic squad that built this whole thing. absolute legends, every single one. give them their flowers πŸ’βœ¨

  • Jakob Truelsen <antialize@gmail.com>
  • Ashish Kulkarni <ashish@kulkarni.dev>
  • Jan Habermann <jan@habermann24.com>
  • Pablo Ruiz GarcΓ­a <pablo.ruiz@gmail.com>
  • Trevor North <trevor@blubolt.com>
  • Nate Pinchot <nate.pinchot@gmail.com>
  • pussbb <pussbb@gmail.com>
  • Aaron Stone <aaron@serendipity.cx>
  • Patrick Widauer @a-ctor
  • Peter van der Tak <pta@ibuildgreen.eu>
  • Benjamin Sinkula <bsinky@gmail.com>
  • Kasper F. Brandt <poizan@poizan.dk>
  • Michael Nitze <michael.nitze@online.de>
  • Rok Dvojmoc <rok.dvojmoc@gmail.com>
  • theirix <theirix@gmail.com>
  • Tomsgu <tomasjakll@gmail.com>
  • Artem Butusov <art.sormy@gmail.com>
  • Christian Sciberras <uuf6429@gmail.com>
  • Daniel M. Lambea <dmlambea@gmail.com>
  • Douglas Bagnall <douglas@paradise.net.nz>
  • peterrehm <peter.rehm@renvest.de>
  • Renan GonΓ§alves <renan.saddam@gmail.com>
  • Ruslan Grabovoy <kudgo.test@gmail.com>
  • Sander Kleykens <sander.kleykens@avnu.be>
  • Adam Thorsen <adam.thorsen@gmail.com>
  • Albin Kerouanton <albin.kerouanton@knplabs.com>
  • Alejandro Dubrovsky <alito@organicrobot.com>
  • Arthur Cinader @acinader
  • Benoit Garret <benoit.garret@gmail.com>
  • Bill Kuker <bkuker@billkuker.com>
  • cptjazz <alexander@jesner.eu>
  • daigot <daigot@rayze.com>
  • Destan Sarpkaya @destan
  • Duncan Smart <duncan.smart@gmail.com>
  • Emil Lerch <emil@lerch.org>
  • Erik Hyrkas <erik.hyrkas@thomsonreuters.com>
  • Erling Linde <erlingwl@gmail.com>
  • FΓ‘bio C. Barrionuevo da Luz <bnafta@gmail.com>
  • Fr33m1nd <lukion@gmx.de>
  • Frank Groeneveld <frank@frankgroeneveld.nl>
  • Immanuel HΓ€ussermann <haeussermann@gmail.com>
  • Jake Petroules <jake.petroules@petroules.com>
  • James Macdonald <james@kingfisher-systems.co.uk>
  • Jason Smith <JasonParallel@gmail.com>
  • John Muccigrosso @Jmuccigr
  • Julien Le Goff <julego@gmail.com>
  • Kay Lukas <kay.lukas@gmail.com>
  • Kurt Revis <krevis@snoize.com>
  • laura @holamon
  • Marc Laporte <marc@laporte.name>
  • Matthew M. Boedicker <matthewm@boedicker.org>
  • Matthieu Bontemps <matthieu.bontemps@gmail.com>
  • Max Sikstrom <max.sikstrom@op5.com>
  • Nolan Neustaeter <github@noolan.ca>
  • Oleg Kostyuk <cub.uanic@gmail.com>
  • Pankaj Jangid <pankaj.jangid@gmail.com>
  • robinbetts <robinbetts@yahoo.com>
  • Sem <spam@esemi.ru>
  • Stefan Weil <sw@weilnetz.de>
  • Stephen Kennedy <sk4425@gmail.com>
  • Steve Shreeve <steve.shreeve@gmail.com>
  • Sven Nierlein <sven@nierlein.org>
  • Tobin Juday <tobinibot@gmail.com>
  • Todd Fisher <todd.fisher@gmail.com>
  • ΠšΠΎΡΡ‚Π°Π΄ΠΈΠ½ Дамянов <maxmight@gmail.com>
  • Emmanuel Bouthenot <kolter@openics.org>
  • Rami @icnocop
  • Khodeir-hubdoc @Khodeir-hubdoc
  • Jonathan Jefferies @jjok
  • Joe Ayers <joseph.ayers@crunchydata.com>
  • Jeffrey Cafferata <jeffrey@jcid.nl>
  • rainabba
  • Mehdi Abbad
  • Lyes Amazouz
  • Pascal Bach
  • MΓ‘rio Silva

and that's the whole page, bestie!! πŸŽ€ you just read the entire WKHTMLTOPDF(1) man page. the footer situation: this one is dated 2009 February 23 and it's filed under WKHTMLTOPDF(1) β€” that's the version/source line and the date, and honestly? vintage but still slaying πŸ’… go forth and make some PDFs, you've got this βœ¨πŸ¦‹

β€” fin β€”