HTML to PDF Command Line Reference

Conversion from HTML to PDF.

usage: html2pdf [options] source
source
Source to be converted. It can be URL, path to a local file or '-' to use stdin as an input text.

Options

Page Setup

-page-size
Set the output page size.
Allowed values:
  • A0
  • A1
  • A2
  • A3
  • A4
  • A5
  • A6
  • Letter
Default: A4
-page-width
Set the output page width. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF.
Constraint:
  • The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".
Default: 8.27in
Examples:
  • "300mm"
  • "9.5in"
-page-height
Set the output page height. Use -1 for a single page PDF. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF.
Constraint:
  • The value must be -1 or specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".
Default: 11.7in
Examples:
  • "15.25in"
  • The height of the page is calculated automatically so that the whole document fits into it.
    "-1"
  • "350mm"
-orientation
Set the output page orientation.
Allowed values:
  • landscape
  • portrait
Default: portrait
-margin-top
Set the output page top margin.
Constraint:
  • The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".
Default: 0.4in
Examples:
  • "1in"
  • "2.5cm"
-margin-right
Set the output page right margin.
Constraint:
  • The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".
Default: 0.4in
Examples:
  • "1in"
  • "2.5cm"
-margin-bottom
Set the output page bottom margin.
Constraint:
  • The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".
Default: 0.4in
Examples:
  • "1in"
  • "2.5cm"
-margin-left
Set the output page left margin.
Constraint:
  • The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".
Default: 0.4in
Examples:
  • "1in"
  • "2.5cm"
-no-margins
Disable page margins.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
Set the page range to print.
Constraint:
  • A comma separated list of page numbers or ranges.
Examples:
  • Just the second page is printed.
    "2"
  • The first and the third page are printed.
    "1,3"
  • Everything except the first page is printed.
    "2-"
  • Just first 3 pages are printed.
    "-3"
  • Pages 3, 6, 7, 8 and 9 are printed.
    "3,6-9"
-page-numbering-offset
Set an offset between physical and logical page numbers.
Default: 0
Examples:
  • The page numbering will start with 0.
    1
  • The page numbering will start with 11 on the first page. It can be useful for joining documents.
    -10
-content-area-x
Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area.
Constraint:
  • The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". It may contain a negative value.
Default: 0in
Examples:
  • "-1in"
  • "2.5cm"
-content-area-y
Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area.
Constraint:
  • The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". It may contain a negative value.
Default: 0in
Examples:
  • "-1in"
  • "2.5cm"
-content-area-width
Set the width of the content area. It should be at least 1 inch.
Constraint:
  • The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".
Default: The width of the print area.
Examples:
  • "8in"
  • "25cm"
-content-area-height
Set the height of the content area. It should be at least 1 inch.
Constraint:
  • The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".
Default: The height of the print area.
Examples:
  • "8in"
  • "25cm"
-css-page-rule-mode
Specifies behavior in presence of CSS @page rules. It may affect the page size, margins and orientation.
Availability: API client >= 5.0.0, converter >= 20.10. See versioning.
Allowed values:
  • default
    The Pdfcrowd API page settings are preferred.
  • mode1
    The converter version 18.10 mode.
  • mode2
    CSS @page rule is preferred.
Default: default
-remove-blank-pages
Specifies which blank pages to exclude from the output document.
Availability: API client >= 5.13.0, converter >= 20.10. See versioning.
Allowed values:
  • trailing
    Trailing blank pages are removed from the document.
  • none
    No blank page is removed from the document.
Default: trailing
-header-url
Load an HTML code from the specified URL and use it as the page header. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows:
  • pdfcrowd-page-count - the total page count of printed pages
  • pdfcrowd-page-number - the current page number
  • pdfcrowd-source-url - the source URL of the converted document
  • pdfcrowd-source-title - the title of the converted document
The following attributes can be used:
  • data-pdfcrowd-number-format - specifies the type of the used numerals. Allowed values:
    • arabic - Arabic numerals, they are used by default
    • roman - Roman numerals
    • eastern-arabic - Eastern Arabic numerals
    • bengali - Bengali numerals
    • devanagari - Devanagari numerals
    • thai - Thai numerals
    • east-asia - Chinese, Vietnamese, Japanese and Korean numerals
    • chinese-formal - Chinese formal numerals
    Please contact us if you need another type of numerals.
    Example:
    <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span>
  • data-pdfcrowd-placement - specifies where to place the source URL. Allowed values:
    • The URL is inserted to the content
      • Example: <span class='pdfcrowd-source-url'></span>
        will produce <span>http://example.com</span>
    • href - the URL is set to the href attribute
      • Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a>
        will produce <a href='http://example.com'>Link to source</a>
    • href-and-content - the URL is set to the href attribute and to the content
      • Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a>
        will produce <a href='http://example.com'>http://example.com</a>
Constraint:
  • The supported protocols are http:// and https://.
Example:
  • "http://myserver.com/header.html"
-header-html
Use the specified HTML code as the page header. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows:
  • pdfcrowd-page-count - the total page count of printed pages
  • pdfcrowd-page-number - the current page number
  • pdfcrowd-source-url - the source URL of the converted document
  • pdfcrowd-source-title - the title of the converted document
The following attributes can be used:
  • data-pdfcrowd-number-format - specifies the type of the used numerals. Allowed values:
    • arabic - Arabic numerals, they are used by default
    • roman - Roman numerals
    • eastern-arabic - Eastern Arabic numerals
    • bengali - Bengali numerals
    • devanagari - Devanagari numerals
    • thai - Thai numerals
    • east-asia - Chinese, Vietnamese, Japanese and Korean numerals
    • chinese-formal - Chinese formal numerals
    Please contact us if you need another type of numerals.
    Example:
    <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span>
  • data-pdfcrowd-placement - specifies where to place the source URL. Allowed values:
    • The URL is inserted to the content
      • Example: <span class='pdfcrowd-source-url'></span>
        will produce <span>http://example.com</span>
    • href - the URL is set to the href attribute
      • Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a>
        will produce <a href='http://example.com'>Link to source</a>
    • href-and-content - the URL is set to the href attribute and to the content
      • Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a>
        will produce <a href='http://example.com'>http://example.com</a>
Example:
  • It displays the page number and the total page count.
    "Page <span class='pdfcrowd-page-number'></span> of <span class='pdfcrowd-page-count'></span> pages"
-header-height
Set the header height.
Constraint:
  • The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt".
Default: 0.5in
Examples:
  • "30mm"
  • "1in"
-zip-header-filename
Set the file name of the header HTML document stored in the input archive. Use this method if the input archive contains multiple HTML documents.
Load an HTML code from the specified URL and use it as the page footer. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows:
  • pdfcrowd-page-count - the total page count of printed pages
  • pdfcrowd-page-number - the current page number
  • pdfcrowd-source-url - the source URL of the converted document
  • pdfcrowd-source-title - the title of the converted document
The following attributes can be used:
  • data-pdfcrowd-number-format - specifies the type of the used numerals. Allowed values:
    • arabic - Arabic numerals, they are used by default
    • roman - Roman numerals
    • eastern-arabic - Eastern Arabic numerals
    • bengali - Bengali numerals
    • devanagari - Devanagari numerals
    • thai - Thai numerals
    • east-asia - Chinese, Vietnamese, Japanese and Korean numerals
    • chinese-formal - Chinese formal numerals
    Please contact us if you need another type of numerals.
    Example:
    <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span>
  • data-pdfcrowd-placement - specifies where to place the source URL. Allowed values:
    • The URL is inserted to the content
      • Example: <span class='pdfcrowd-source-url'></span>
        will produce <span>http://example.com</span>
    • href - the URL is set to the href attribute
      • Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a>
        will produce <a href='http://example.com'>Link to source</a>
    • href-and-content - the URL is set to the href attribute and to the content
      • Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a>
        will produce <a href='http://example.com'>http://example.com</a>
Example:
  • "http://myserver.com/header.html"
Use the specified HTML as the page footer. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows:
  • pdfcrowd-page-count - the total page count of printed pages
  • pdfcrowd-page-number - the current page number
  • pdfcrowd-source-url - the source URL of the converted document
  • pdfcrowd-source-title - the title of the converted document
The following attributes can be used:
  • data-pdfcrowd-number-format - specifies the type of the used numerals. Allowed values:
    • arabic - Arabic numerals, they are used by default
    • roman - Roman numerals
    • eastern-arabic - Eastern Arabic numerals
    • bengali - Bengali numerals
    • devanagari - Devanagari numerals
    • thai - Thai numerals
    • east-asia - Chinese, Vietnamese, Japanese and Korean numerals
    • chinese-formal - Chinese formal numerals
    Please contact us if you need another type of numerals.
    Example:
    <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span>
  • data-pdfcrowd-placement - specifies where to place the source URL. Allowed values:
    • The URL is inserted to the content
      • Example: <span class='pdfcrowd-source-url'></span>
        will produce <span>http://example.com</span>
    • href - the URL is set to the href attribute
      • Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a>
        will produce <a href='http://example.com'>Link to source</a>
    • href-and-content - the URL is set to the href attribute and to the content
      • Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a>
        will produce <a href='http://example.com'>http://example.com</a>
Example:
  • It displays the page number and the total page count.
    "Page <span class='pdfcrowd-page-number'></span> of <span class='pdfcrowd-page-count'></span> pages"
Set the footer height.
Examples:
  • "30mm"
  • "1in"
Set the file name of the footer HTML document stored in the input archive. Use this method if the input archive contains multiple HTML documents.
Disable horizontal page margins for header and footer. The header/footer contents width will be equal to the physical page width.
Availability: API client >= 5.0.0, converter >= 20.10. See versioning.
-exclude-header-on-pages
The page header is not printed on the specified pages.
Constraint:
  • A comma separated list of page numbers.
Examples:
  • The header is not printed on the second page.
    "2"
  • The header is not printed on the first and the last page.
    "1,-1"
The page footer is not printed on the specified pages.
Examples:
  • The footer is not printed on the second page.
    "2"
  • The footer is not printed on the first and the last page.
    "1,-1"
Set the scaling factor (zoom) for the header and footer.
Example:
  • 50

Watermark & Background

-page-watermark
Apply a watermark to each page of the output PDF file. A watermark can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the watermark.
Constraint:
  • The file must exist and not be empty.
Examples:
  • "/home/user/john/watermark.pdf"
  • "/home/user/john/watermark.png"
-page-watermark-url
Load a file from the specified URL and apply the file as a watermark to each page of the output PDF. A watermark can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the watermark.
Constraint:
  • The supported protocols are http:// and https://.
Examples:
  • "http://myserver.com/watermark.pdf"
  • "http://myserver.com/watermark.png"
-multipage-watermark
Apply each page of a watermark to the corresponding page of the output PDF. A watermark can be either a PDF or an image.
Constraint:
  • The file must exist and not be empty.
Examples:
  • "/home/user/john/watermark.pdf"
  • "/home/user/john/watermark.png"
-multipage-watermark-url
Load a file from the specified URL and apply each page of the file as a watermark to the corresponding page of the output PDF. A watermark can be either a PDF or an image.
Constraint:
  • The supported protocols are http:// and https://.
Examples:
  • "http://myserver.com/watermark.pdf"
  • "http://myserver.com/watermark.png"
-page-background
Apply a background to each page of the output PDF file. A background can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the background.
Constraint:
  • The file must exist and not be empty.
Examples:
  • "/home/user/john/background.pdf"
  • "/home/user/john/background.png"
-page-background-url
Load a file from the specified URL and apply the file as a background to each page of the output PDF. A background can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the background.
Constraint:
  • The supported protocols are http:// and https://.
Examples:
  • "http://myserver.com/background.pdf"
  • "http://myserver.com/background.png"
-multipage-background
Apply each page of a background to the corresponding page of the output PDF. A background can be either a PDF or an image.
Constraint:
  • The file must exist and not be empty.
Examples:
  • "/home/user/john/background.pdf"
  • "/home/user/john/background.png"
-multipage-background-url
Load a file from the specified URL and apply each page of the file as a background to the corresponding page of the output PDF. A background can be either a PDF or an image.
Constraint:
  • The supported protocols are http:// and https://.
Examples:
  • "http://myserver.com/background.pdf"
  • "http://myserver.com/background.png"
-page-background-color
The page background color in RGB or RGBA hexadecimal format. The color fills the entire page regardless of the margins.
Constraint:
  • The value must be in RRGGBB or RRGGBBAA hexadecimal format.
Examples:
  • red color
    "FF0000"
  • green color
    "00ff00"
  • green color with 50% opacity
    "00ff0080"

General Options

-use-print-media
Use the print version of the page if available (@media print).
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-no-background
Do not print the background graphics.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-disable-javascript
Do not execute JavaScript.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-disable-image-loading
Do not load images.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-disable-remote-fonts
Disable loading fonts from remote sources.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-use-mobile-user-agent
Use a mobile user agent.
Availability: API client >= 5.3.0, converter >= 20.10. See versioning.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-load-iframes
Specifies how iframes are handled.
Availability: API client >= 5.0.0, converter >= 20.10. See versioning.
Allowed values:
  • all
    All iframes are loaded.
  • same-origin
    Only iframes with the same origin as the main page are loaded.
  • none
    Iframe loading is disabled.
Default: all
-block-ads
Try to block ads. Enabling this option can produce smaller output and speed up the conversion.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-default-encoding
Set the default HTML content text encoding.
Default: auto detect
Examples:
  • Set to use Latin-2 encoding.
    "iso8859-2"
  • Set to use UTF-8 encoding.
    "utf-8"
-locale
Set the locale for the conversion. This may affect the output format of dates, times and numbers.
Availability: API client >= 5.0.0, converter >= 20.10. See versioning.
Default: en-US
Example:
  • Set to use Japanese locale.
    "ja-JP"
-http-auth-user-name
Set the HTTP authentication user name.
Example:
  • "John"
-http-auth-password
Set the HTTP authentication password.
Example:
  • "123456"
-cookies
Set cookies that are sent in Pdfcrowd HTTP requests.
Example:
  • "session=6d7184b3bf35;token=2710"
-verify-ssl-certificates
Do not allow insecure HTTPS connections.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-fail-on-main-url-error
Abort the conversion if the main URL HTTP status code is greater than or equal to 400.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-fail-on-any-url-error
Abort the conversion if any of the sub-request HTTP status code is greater than or equal to 400 or if some sub-requests are still pending. See details in a debug log.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-no-xpdfcrowd-header
Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-custom-css
Apply custom CSS to the input HTML document. It allows you to modify the visual appearance and layout of your HTML content dynamically. Tip: Using !important in custom CSS provides a way to prioritize and override conflicting styles.
Availability: API client >= 5.14.0, converter >= 20.10. See versioning.
Examples:
  • Set the page background color to gray.
    "body { background-color: gray; }"
  • Do not show nav HTML elements and the element with ad-block ID in the output PDF.
    "nav, #ad-block { display: none !important; }"
-custom-javascript
Run a custom JavaScript after the document is loaded and ready to print. The script is intended for post-load DOM manipulation (add/remove elements, update CSS, ...). In addition to the standard browser APIs, the custom JavaScript code can use helper functions from our JavaScript library.
Example:
  • Set the page background color to gray.
    "document.body.style.setProperty('background-color', 'gray', 'important')"
-on-load-javascript
Run a custom JavaScript right after the document is loaded. The script is intended for early DOM manipulation (add/remove elements, update CSS, ...). In addition to the standard browser APIs, the custom JavaScript code can use helper functions from our JavaScript library.
Example:
  • Set the page background color to gray.
    "document.body.style.setProperty('background-color', 'gray', 'important')"
-custom-http-header
Set a custom HTTP header that is sent in Pdfcrowd HTTP requests.
Constraint:
  • A string containing the header name and value separated by a colon.
Example:
  • "X-My-Client-ID:k2017-12345"
-javascript-delay
Wait the specified number of milliseconds to finish all JavaScript after the document is loaded. Your API license defines the maximum wait time by "Max Delay" parameter.
Constraint:
  • Must be a positive integer number or 0.
Default: 200
Example:
  • Wait for 2 seconds.
    2000
-element-to-convert
Convert only the specified element from the main document and its children. The element is specified by one or more CSS selectors. If the element is not found, the conversion fails. If multiple elements are found, the first one is used.
Examples:
  • The first element with the id main-content is converted.
    "#main-content"
  • The first element with the class name main-content is converted.
    ".main-content"
  • The first element with the tag name table is converted.
    "table"
  • The first element with the tag name table or with the id main-content is converted.
    "table, #main-content"
  • The first element <p class="article"> within <div class="user-panel main"> is converted.
    "div.user-panel.main p.article"
-element-to-convert-mode
Specify the DOM handling when only a part of the document is converted. This can affect the CSS rules used.
Allowed values:
  • cut-out
    The element and its children are cut out of the document.
  • remove-siblings
    All element's siblings are removed.
  • hide-siblings
    All element's siblings are hidden.
Default: cut-out
-wait-for-element
Wait for the specified element in a source document. The element is specified by one or more CSS selectors. The element is searched for in the main document and all iframes. If the element is not found, the conversion fails. Your API license defines the maximum wait time by "Max Delay" parameter.
Examples:
  • Wait until an element with the id main-content is found.
    "#main-content"
  • Wait until an element with the class name main-content is found.
    ".main-content"
  • Wait until an element with the tag name table is found.
    "table"
  • Wait until an element with the tag name table or with the id main-content is found.
    "table, #main-content"
  • Wait until <p class="article"> is found within <div class="user-panel main">.
    "div.user-panel.main p.article"
-auto-detect-element-to-convert
The main HTML element for conversion is detected automatically.
Availability: API client >= 5.5.0, converter >= 20.10. See versioning.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-readability-enhancements
The input HTML is automatically enhanced to improve the readability.
Availability: API client >= 5.5.0, converter >= 20.10. See versioning.
Allowed values:
  • none
    No enhancements are used.
  • readability-v1
    Version 1 of the enhancements is used.
  • readability-v2
    Version 2 of the enhancements is used.
  • readability-v3
    Version 3 of the enhancements is used.
  • readability-v4
    Version 4 of the enhancements is used.
Default: none
-viewport-width
Set the viewport width in pixels. The viewport is the user's visible area of the page.
Constraint:
  • The value must be in the range 96-65000.
Default: 1024
Example:
  • Full HD width.
    1920
-viewport-height
Set the viewport height in pixels. The viewport is the user's visible area of the page. If the input HTML uses lazily loaded images, try using a large value that covers the entire height of the HTML, e.g. 100000.
Constraint:
  • Must be a positive integer number.
Default: 768
Example:
  • 15000
-rendering-mode
Set the rendering mode.
Allowed values:
  • default
    The mode based on the standard browser print functionality.
  • viewport
    The viewport width affects the @media min-width and max-width CSS properties. This mode can be used to choose a particular version (mobile, desktop, ..) of a responsive page.
Default: default
-smart-scaling-mode
Specifies the scaling mode used for fitting the HTML contents to the print area.
Allowed values:
  • default
    The mode based on the standard browser print functionality.
  • disabled
    No smart scaling is performed.
  • viewport-fit
    The viewport width fits the print area width.
  • content-fit
    The HTML contents width fits the print area width.
  • single-page-fit
    The whole HTML contents fits the print area of a single page.
  • single-page-fit-ex
    The whole HTML contents fits the print area of a single page with respect to the page height/width ratio.
  • mode1
    Scaling mode 1 is applied.
Default: default
-scale-factor
Set the scaling factor (zoom) for the main page area.
Constraint:
  • The value must be in the range 10-500.
Default: 100
Example:
  • 50
-disable-smart-shrinking
Disable the intelligent shrinking strategy that tries to optimally fit the HTML contents to a PDF page.
API client < 5.0.0. Smart scaling mode1 can be used instead. See versioning.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-jpeg-quality
Set the quality of embedded JPEG images. A lower quality results in a smaller PDF file but can lead to compression artifacts.
Constraint:
  • The value must be in the range 1-100.
Default: 100
Example:
  • Set 70% quality as a compromise between image quality and image size.
    70
-convert-images-to-jpeg
Specify which image types will be converted to JPEG. Converting lossless compression image formats (PNG, GIF, ...) to JPEG may result in a smaller PDF file.
Allowed values:
  • none
    No image conversion is done.
  • opaque
    Only opaque images are converted to JPEG images.
  • all
    All images are converted to JPEG images. The JPEG format does not support transparency so the transparent color is replaced by a PDF page background color.
Default: none
-image-dpi
Set the DPI of images in PDF. A lower DPI may result in a smaller PDF file. If the specified DPI is higher than the actual image DPI, the original image DPI is retained (no upscaling is performed). Use 0 to leave the images unaltered.
Constraint:
  • Must be a positive integer number or 0.
Default: 0
Examples:
  • No change of the source image is done.
    0
  • Screen-only view lower DPI.
    72
  • Screen-only view recommended DPI.
    96
  • Ebook typical DPI.
    150
  • Printer standard DPI.
    300

PDF Format

Miscellaneous values for PDF output.

-enable-pdf-forms
Convert HTML forms to fillable PDF forms. Details can be found in the blog post.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-linearize
Create linearized PDF. This is also known as Fast Web View.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-encrypt
Encrypt the PDF. This prevents search engines from indexing the contents.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-user-password
Protect the PDF with a user password. When a PDF has a user password, it must be supplied in order to view the document and to perform operations allowed by the access permissions.
Example:
  • "123456"
-owner-password
Protect the PDF with an owner password. Supplying an owner password grants unlimited access to the PDF including changing the passwords and access permissions.
Example:
  • "123456"
-no-print
Disallow printing of the output PDF.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-no-modify
Disallow modification of the output PDF.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-no-copy
Disallow text and graphics extraction from the output PDF.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-title
Set the title of the PDF.
Example:
  • "My Resume"
-subject
Set the subject of the PDF.
Example:
  • "CV - Software Developer"
-author
Set the author of the PDF.
Example:
  • "John Doe"
-keywords
Associate keywords with the document.
Example:
  • "software developer, Unix, databases"
-extract-meta-tags
Extract meta tags (author, keywords and description) from the input HTML and use them in the output PDF.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False

Viewer Preferences

These preferences specify how a PDF viewer should present the document. The preferences may be ignored by some PDF viewers.

-page-layout
Specify the page layout to be used when the document is opened.
Allowed values:
  • single-page
    Display one page at a time.
  • one-column
    Display the pages in one column.
  • two-column-left
    Display the pages in two columns, with odd-numbered pages on the left.
  • two-column-right
    Display the pages in two columns, with odd-numbered pages on the right.
-page-mode
Specify how the document should be displayed when opened.
Allowed values:
  • full-screen
    Full-screen mode.
  • thumbnails
    Thumbnail images are visible.
  • outlines
    Document outline is visible.
-initial-zoom-type
Specify how the page should be displayed when opened.
Allowed values:
  • fit-width
    The page content is magnified just enough to fit the entire width of the page within the window.
  • fit-height
    The page content is magnified just enough to fit the entire height of the page within the window.
  • fit-page
    The page content is magnified just enough to fit the entire page within the window both horizontally and vertically. If the required horizontal and vertical magnification factors are different, use the smaller of the two, centering the page within the window in the other dimension.
-initial-page
Display the specified page when the document is opened.
Constraint:
  • Must be a positive integer number.
Example:
  • 2
-initial-zoom
Specify the initial page zoom in percents when the document is opened.
Constraint:
  • Must be a positive integer number.
Example:
  • 50
-hide-toolbar
Specify whether to hide the viewer application's tool bars when the document is active.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-hide-menubar
Specify whether to hide the viewer application's menu bar when the document is active.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-hide-window-ui
Specify whether to hide user interface elements in the document's window (such as scroll bars and navigation controls), leaving only the document's contents displayed.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-fit-window
Specify whether to resize the document's window to fit the size of the first displayed page.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-center-window
Specify whether to position the document's window in the center of the screen.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-display-title
Specify whether the window's title bar should display the document title. If false , the title bar should instead display the name of the PDF file containing the document.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-right-to-left
Set the predominant reading order for text to right-to-left. This option has no direct effect on the document's contents or page numbering but can be used to determine the relative positioning of pages when displayed side by side or printed n-up
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False

Data

Methods related to HTML template rendering.

-data-string
Set the input data for template rendering. The data format can be JSON, XML, YAML or CSV.
Example:
  • JSON data.
    "{"recipient": "Anna May", "sender": "John Doe"}"
-data-file
Load the input data for template rendering from the specified file. The data format can be JSON, XML, YAML or CSV.
Example:
  • "/home/user/john/data.json"
-data-format
Specify the input data format.
Allowed values:
  • auto
    the data format is auto detected
  • json
  • xml
  • yaml
  • csv
Default: auto
-data-encoding
Set the encoding of the data file set by setDataFile.
Default: utf-8
Example:
  • Set to use Latin-2 encoding.
    "iso8859-2"
-data-ignore-undefined
Ignore undefined variables in the HTML template. The default mode is strict so any undefined variable causes the conversion to fail. You can use {% if variable is defined %} to check if the variable is defined.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-data-auto-escape
Auto escape HTML symbols in the input data before placing them into the output.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-data-trim-blocks
Auto trim whitespace around each template command block.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-data-options
Set the advanced data options:
  • csv_delimiter - The CSV data delimiter, the default is ,.
  • xml_remove_root - Remove the root XML element from the input data.
  • data_root - The name of the root element inserted into the input data without a root node (e.g. CSV), the default is data.
Examples:
  • Use semicolon to separate CSV data.
    "csv_delimiter=;"
  • Name the root of data rows and use the name in the template loop {% for row in rows %}...{% endfor %}.
    "data_root=rows"
  • Remove XML root so it the HTML template can be more simple.
    "xml_remove_root=1"

Miscellaneous

-debug-log
Turn on the debug logging. Details about the conversion are stored in the debug log. The URL of the log can be obtained from the getDebugLogUrl method or available in conversion statistics.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-tag
Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
Example:
  • "client-1234"
-http-proxy
A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTP scheme. It can help to circumvent regional restrictions or provide limited access to your intranet.
Constraint:
  • The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
Examples:
  • "myproxy.com:8080"
  • "113.25.84.10:33333"
-https-proxy
A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTPS scheme. It can help to circumvent regional restrictions or provide limited access to your intranet.
Constraint:
  • The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
Examples:
  • "myproxy.com:443"
  • "113.25.84.10:44333"
-client-certificate
A client certificate to authenticate Pdfcrowd converter on your web server. The certificate is used for two-way SSL/TLS authentication and adds extra security.
Constraint:
  • The file must exist and not be empty.
Example:
  • "/home/user/john/pdfcrowd.crt"
-client-certificate-password
A password for PKCS12 file with a client certificate if it is needed.
Example:
  • "123456"

Tweaks

Expert options for fine-tuning output.

-layout-dpi
Set the internal DPI resolution used for positioning of PDF contents. It can help in situations when there are small inaccuracies in the PDF. It is recommended to use values that are a multiple of 72, such as 288 or 360.
Availability: API client >= 5.0.0, converter >= 20.10. See versioning.
Constraint:
  • The value must be in the range of 72-600.
Default: 300
Example:
  • 144
-contents-matrix
A 2D transformation matrix applied to the main contents on each page. The origin [0,0] is located at the top-left corner of the contents. The resolution is 72 dpi.
Availability: API client >= 5.0.0, converter >= 20.10. See versioning.
Default: 1,0,0,0,1,0
Examples:
  • Fine tune the contents height.
    "1,0,0,0,1.001,0"
  • Translate the contents by -10 points in both directions.
    "1,0,-10,0,1,-10"
-header-matrix
A 2D transformation matrix applied to the page header contents. The origin [0,0] is located at the top-left corner of the header. The resolution is 72 dpi.
Availability: API client >= 5.0.0, converter >= 20.10. See versioning.
Default: 1,0,0,0,1,0
Examples:
  • Fine tune the header contents height.
    "1,0,0,0,1.001,0"
  • Translate the header contents by -10 points in both directions.
    "1,0,-10,0,1,-10"
A 2D transformation matrix applied to the page footer contents. The origin [0,0] is located at the top-left corner of the footer. The resolution is 72 dpi.
Availability: API client >= 5.0.0, converter >= 20.10. See versioning.
Examples:
  • Fine tune the footer contents height.
    "1,0,0,0,1.001,0"
  • Translate the footer contents by -10 points in both directions.
    "1,0,-10,0,1,-10"
-disable-page-height-optimization
Disable automatic height adjustment that compensates for pixel to point rounding errors.
Availability: API client >= 5.0.0, converter >= 20.10. See versioning.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False
-main-document-css-annotation
Add special CSS classes to the main document's body element. This allows applying custom styling based on these classes:
  • pdfcrowd-page-X - where X is the current page number
  • pdfcrowd-page-odd - odd page
  • pdfcrowd-page-even - even page
Availability: API client >= 5.0.0, converter >= 20.10. See versioning.
Allowed values:
  • true, 1 or on
  • false, 0 or off
Default: False

Warning

If your custom styling affects the contents area size (e.g. by using different margins, padding, border width), the resulting PDF may contain duplicit contents or some contents may be missing.

Example:
Add special CSS classes to the header/footer's body element. This allows applying custom styling based on these classes:
  • pdfcrowd-page-X - where X is the current page number
  • pdfcrowd-page-count-X - where X is the total page count
  • pdfcrowd-page-first - the first page
  • pdfcrowd-page-last - the last page
  • pdfcrowd-page-odd - odd page
  • pdfcrowd-page-even - even page
Availability: API client >= 5.0.0, converter >= 20.10. See versioning.
Examples:
-max-loading-time
Set the maximum time to load the page and its resources. After this time, all requests will be considered successful. This can be useful to ensure that the conversion does not timeout. Use this method if there is no other way to fix page loading.
Availability: API client >= 5.15.0, converter >= 20.10. See versioning.
Constraint:
  • The value must be in the range 10-30.