# phpman > man > WKHTMLTOPDF(1)

> **TLDR:** Convert HTML documents or web pages into PDF files.
>
- 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}}`

*Source: tldr-pages*

---

[WKHTMLTOPDF(1)](https://www.chedong.com/phpMan.php/man/WKHTMLTOPDF/1/markdown)                         General Commands Manual                        [WKHTMLTOPDF(1)](https://www.chedong.com/phpMan.php/man/WKHTMLTOPDF/1/markdown)



## Name
       wkhtmltopdf - html to pdf converter



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



### Document objects
       wkhtmltopdf is able to put several objects into the output file, an object is either a single
       webpage, a cover webpage or a table of contents.  The objects are put into the  output  docu‐
       ment  in  the order they are specified on the command line, options can be specified on a per
       object basis or in the global options area. Options from the Global Options section can  only
       be placed in the global options area.

       A page objects puts the content of a single webpage into the output document.

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

       Options  for  the page object can be placed in the global options and the page options areas.
       The applicable options can be found in the Page Options and Headers And Footer  Options  sec‐
       tions.

       A  cover objects puts the content of a single webpage into the output document, the page does
       not appear in the table of contents, and does not have headers and footers.

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

       All options that can be specified for a page object can also be specified for a cover.

       A table of contents object inserts a table of contents into the output document.

         toc [TOC OPTION]...

       All options that can be specified for a page object can also be specified for a toc,  further
       more  the  options from the TOC Options section can also be applied. The table of contents is
       generated via XSLT which means that it can be styled to look however you want it to look.  To
       get  an  idea  of  how  to  do  this  you can dump the default xslt document by supplying the
       --dump-default-toc-xsl, and the outline it works on by supplying --dump-outline, see the Out‐
       line Options section.



## Description
       Converts one or more HTML pages into a PDF document, **not** using wkhtmltopdf patched qt.



### Global Options
           **--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
              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
              Set the page bottom margin
### -L, --margin-left
              Set the page left margin
### -R, --margin-right
              Set the page right margin
### -T, --margin-top
              Set the page top margin
### -O, --orientation
              Set orientation to Landscape or Portrait
           **--page-height** _<unitreal>_
              Page height
### -s, --page-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
           **--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 explic‐
              itly 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
              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  information will be read from the environment variables: proxy, all_proxy
       and http_proxy, proxy options can also by specified 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):

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



### Reduced Functionality
       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.



### 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#Paper>‐
       Size-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,

       When  --read-args-from-stdin  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.  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  so‐
       lution  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
       If you experience bugs  or  want  to  request  new  features  please  visit  <<https://wkhtml>‐
       topdf.org/support.html>



## Authors
         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





                                          2009 February 23                            [WKHTMLTOPDF(1)](https://www.chedong.com/phpMan.php/man/WKHTMLTOPDF/1/markdown)
