Advanced Options – WKHTMLTOPDF
For the WKHTMLTOPDF endpoint, you have the ability to pass in a variety of advanced options as a JSON object as part of the
payload. Below are the set of options that we support with wkhtmltopdf.
Sample Payload with Advanced Options
{
"html": "Hello World",
"options": {
"orientation": "landscape",
"dpi": 300,
"grayscale": true
}
}
Page Options
Attribute | Type | Description |
---|---|---|
copies | Integer | Number of copies to print into the pdf file (default 1) |
dpi | Integer | Change the dpi explicitly (this has no effect on X11 based systems) (default 96) |
grayscale | Boolean | PDF will be generated in grayscale |
imageDpi | Integer | When embedding images scale them down to this dpi (default 600) |
imageQuality | Integer | When jpeg compressing images use this quality (default 94) |
lowquality | Boolean | Generates lower quality pdf/ps. Useful to shrink the result document space |
marginBottom | Unit, mm | Set the page bottom margin |
marginLeft | Unit, mm | Set the page left margin (default 10mm) |
marginRight | Unit, mm | Set the page right margin (default 10mm) |
marginTop | Unit, mm | Set the page top margin |
orientation | landscape/portrait | Set orientation to Landscape or Portrait (default Portrait) |
pageHeight | Unit, mm | Page height |
pageSize | Size | Set paper size to: A4, Letter, etc. (default A4). See full list of page sizes here |
pageWidth | Unit, mm | Page width | printMediaType | Boolean | Use print styles instead of “screen”. Can improve readability and layout in some cases. |
noPdfCompression | Boolean | Do not use lossless compression on pdf objects |
title | String | The title of the generated pdf file (The title of the first document is used if not specified) |
disableExternalLinks | Boolean | Do not make links to remote web pages |
enableExternalLinks | Boolean | Make links to remote web pages (default) |
disableForms | Boolean | Do not turn HTML form fields into pdf form fields (default) |
enableForms | Boolean | Turn HTML form fields into pdf form fields |
images | Boolean | Do load or print images (default) |
noImages | Boolean | Do not load or print images |
disableInternalLinks | Boolean | Do not make local links |
enableInternalLinks | Boolean | Make local links (default) |
disableJavascript | Boolean | Do not allow web pages to run javascript |
enableJavascript | Boolean | Do allow web pages to run javascript (default) |
javascriptDelay | Milliseconds | Wait some milliseconds for javascript finish (default 200) |
keepRelativeLinks | Boolean | Keep relative external links as relative external links |
minimumFontSize | Integer | Minimum font size |
pageOffset | Integer | Set the starting page number (default 0) |
disableSmartShrinking | Boolean | Disable the intelligent shrinking strategy used by WebKit that makes the pixel/dpi ratio none constant |
enableSmartShrinking | Boolean | Enable the intelligent shrinking strategy used by WebKit that makes the pixel/dpi ratio none constant (default) |
zoom | Float | Use this zoom factor (default 1) |
Header / Footer Options
Headers and footers can be added to the document. In header and footer text string the following variables will be replaced
- [page] Replaced by the number of the pages currently being printed
- [frompage] Replaced by the number of the first page to be printed
- [topage] Replaced by the number of the last page to be printed
- [webpage] Replaced by the URL of the page being printed
- [section] Replaced by the name of the current section
- [subsection] Replaced by the name of the current subsection
- [date] Replaced by the current date in system local format
- [isodate] Replaced by the current date in ISO 8601 extended format
- [time] Replaced by the current time in system local format
- [title] Replaced by the title of the of the current page object
- [doctitle] Replaced by the title of the output document
- [sitepage] Replaced by the number of the page in the current site being converted
- [sitepages] Replaced by the number of pages in the current site being converted
Attribute | Type | Description |
---|---|---|
footerCenter | String | Centered footer text |
footerFontName | String | Set footer font name (default Arial) |
footerFontSize | Size | Set footer font size (default 12) |
footerHtml | Url | Adds a html footer |
footerLeft | String | Left aligned footer text |
footerLine | Boolean | Display line above the footer |
noFooterLine | Boolean | Do not display line above the footer (default) |
footerRight | String | Right aligned footer text |
footerSpacing | Units, mm | Spacing between footer and content in mm (default 0) |
headerCenter | String | Centered header text |
headerFontName | String | Set header font name (default Arial) |
headerFontSize | Size | Set header font size (default 12) |
headerHtml | Url | Adds a html header |
headerLeft | String | Left aligned header text |
headerLine | Boolean | Display line below the header |
noHeaderLine | Boolean | Do not display line below the header (default) |
headerRight | String | Right aligned header text |
headerSpacing | Units, mm | Spacing between header and content in mm (default 0) |