WKHTMLTOPDF(1)
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,warnorinfo-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 toLandscapeorPortrait--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-headerfor each resource request.--no-custom-header-propagationβ Do not add HTTP headers specified by--custom-headerfor 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,ignoreorskip--load-media-error-handling <handler>β Specify how to handle media files that fail to load:abort,ignoreorskip--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 untilwindow.statusis 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-ctorPeter 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@acinaderBenoit Garret<benoit.garret@gmail.com>Bill Kuker<bkuker@billkuker.com>cptjazz<alexander@jesner.eu>daigot<daigot@rayze.com>Destan Sarpkaya@destanDuncan 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@JmuccigrJulien Le Goff<julego@gmail.com>Kay Lukas<kay.lukas@gmail.com>Kurt Revis<krevis@snoize.com>laura@holamonMarc 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@icnocopKhodeir-hubdoc@Khodeir-hubdocJonathan Jefferies@jjokJoe Ayers<joseph.ayers@crunchydata.com>Jeffrey Cafferata<jeffrey@jcid.nl>rainabbaMehdi AbbadLyes AmazouzPascal BachMΓ‘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 β
π¦ where this page comes from
- debian bookworm: wkhtmltopdf 0.12.6-2+b1 Β· LGPL-3.0-only
- fedora 43: wkhtmltopdf 0.12.6-7.fc43 Β· LGPL-3.0-or-later
- fedora 43: wkhtmltopdf 0.12.6-7.fc43 Β· LGPL-3.0-or-later
- fedora 44: wkhtmltopdf 0.12.6-9.fc44 Β· LGPL-3.0-or-later
- fedora 44: wkhtmltopdf 0.12.6-9.fc44 Β· LGPL-3.0-or-later
- ubuntu jammy: wkhtmltopdf 0.12.6-2 Β· LGPL-3.0-only
- ubuntu noble: wkhtmltopdf 0.12.6-2build2 Β· LGPL-3.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms