HTML to Image / HTTP API Reference

Conversion Format

output_format

The format of the output file.

Default:
png
Allowed Values:
  • png
  • jpg
  • gif
  • tiff
  • bmp
  • ico
  • ppm
  • pgm
  • pbm
  • pnm
  • psb
  • pct
  • ras
  • tga
  • sgi
  • sun
  • webp

Conversion Input

url

The address of the web page to convert.

Constraint:
  • Supported protocols are http:// and https://.

file

The path to a local file to convert.
The file can be either a single file or an archive (.tar.gz, .tar.bz2, or .zip).
If the HTML document refers to local external assets (images, style sheets, javascript), zip the document together with the assets.

Constraints:
  • The file must exist and not be empty.
  • The file name must have a valid extension.

text

The string content to convert.

zip_main_filename

Set the file name of the main HTML document stored in the input archive. If not specified, the first HTML file in the archive is used for conversion. Use this method if the input archive contains multiple HTML documents.

Response

output_name

The file name of the created file (max 180 chars). If not specified then the name is auto-generated.

content_disposition

The value of the Content-Disposition HTTP header sent in the response.

Default:
attachment
Allowed Values:
  • attachment — Forces the browser to pop up a Save As dialog.
  • inline — The browser will open the result file in the browser window.

Image Output

screenshot_width

Set the output image width in pixels.

Constraint:
  • The accepted range is 96-65000.
Default:
1024
Example:
  • Full HD width: 1920

screenshot_height

Set the output image height in pixels. If it is not specified, actual document height is used.

Constraint:
  • Must be a positive integer.
Example:
  • Full HD height: 1080

scale_factor

Set the scaling factor (zoom) for the output image.

Constraint:
  • Must be a positive integer.
Default:
100
Example:
  • Reduce image for thumbnails: 50

background_color

The output image background color.

Availability:
Available for converters >= 20.10. See versioning.
Constraint:
  • The value must be in RRGGBB or RRGGBBAA hexadecimal format.
Examples:
  • red color: FF0000
  • fully transparent background: 00000000
  • green color with 50% opacity: 00ff0080
  • green color: 00ff00

General Options

use_print_media

Use the print version of the page if available (@media print).

Default:
false
Allowed Values:
  • true, 1 or on
  • false, 0 or off

no_background

Do not print the background graphics.

Default:
false
Allowed Values:
  • true, 1 or on
  • false, 0 or off

disable_javascript

Do not execute JavaScript.

Default:
false
Allowed Values:
  • true, 1 or on
  • false, 0 or off

disable_image_loading

Do not load images.

Default:
false
Allowed Values:
  • true, 1 or on
  • false, 0 or off

disable_remote_fonts

Disable loading fonts from remote sources.

Default:
false
Allowed Values:
  • true, 1 or on
  • false, 0 or off

use_mobile_user_agent

Deprecated Replaced with: converter_user_agent

Use a mobile user agent.

Availability:
Available for converters >= 20.10. See versioning.
Default:
false
Allowed Values:
  • true, 1 or on
  • false, 0 or off

load_iframes

Specifies how iframes are handled.

Availability:
Available for converters >= 20.10. See versioning.
Default:
all
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.

block_ads

Try to block ads. Enabling this option can produce smaller output and speed up the conversion.

Default:
false
Allowed Values:
  • true, 1 or on
  • false, 0 or off

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:
Available for converters >= 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:
  • HTTP auth username: John

http_auth_password

Set the HTTP authentication password.

Example:
  • Simple password for protected sites: 123456

cookies

Set HTTP cookies to be included in all requests made by the converter.

Example:
  • Multiple cookies for authentication: session=6d7184b3bf35;token=2710

verify_ssl_certificates

Do not allow insecure HTTPS connections.

Default:
false
Allowed Values:
  • true, 1 or on
  • false, 0 or off

fail_on_main_url_error

Abort the conversion if the main URL HTTP status code is greater than or equal to 400.

Default:
false
Allowed Values:
  • true, 1 or on
  • false, 0 or off

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.

Default:
false
Allowed Values:
  • true, 1 or on
  • false, 0 or off

no_xpdfcrowd_header

Do not send the X-Pdfcrowd HTTP header in PDFCrowd HTTP requests.

Default:
false
Allowed Values:
  • true, 1 or on
  • false, 0 or off

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:
Available for converters >= 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 to be included in all requests made by the converter.

Constraint:
  • A string containing the header name and value separated by a colon.
Example:
  • API client tracking header: X-My-Client-ID:k2017-12345

javascript_delay

Wait the specified number of milliseconds to finish all JavaScript after the document is loaded. Your license defines the maximum wait time by "Max Delay" parameter.

Constraint:
  • Must be a positive integer 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.

Default:
cut-out
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.

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 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:
Available for converters >= 20.10. See versioning.
Default:
false
Allowed Values:
  • true, 1 or on
  • false, 0 or off

readability_enhancements

The input HTML is automatically enhanced to improve the readability.

Availability:
Available for converters >= 20.10. See versioning.
Default:
none
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.

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:
  • Template variables for mail merge: {"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:
  • External data for template rendering: /home/user/john/data.json

data_format

Specify the input data format.

Default:
auto
Allowed Values:
  • auto — the data format is auto detected
  • json
  • xml
  • yaml
  • csv

data_encoding

Set the encoding of the data file set by data_file.

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.

Default:
false
Allowed Values:
  • true, 1 or on
  • false, 0 or off

data_auto_escape

Auto escape HTML symbols in the input data before placing them into the output.

Default:
false
Allowed Values:
  • true, 1 or on
  • false, 0 or off

data_trim_blocks

Auto trim whitespace around each template command block.

Default:
false
Allowed Values:
  • true, 1 or on
  • false, 0 or off

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 is returned in the x-pdfcrowd-debug-log response header or available in conversion statistics.

Default:
false
Allowed Values:
  • true, 1 or on
  • false, 0 or off

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:
  • Track job in analytics: client-1234

http_proxy

A proxy server used by the 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:
  • Corporate proxy server: myproxy.com:8080
  • Direct IP proxy connection: 113.25.84.10:33333

https_proxy

A proxy server used by the 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:
  • Secure proxy for HTTPS: myproxy.com:443
  • Direct secure proxy IP: 113.25.84.10:44333

client_certificate

A client certificate to authenticate the 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:
  • Custom CA certificate path: /home/user/john/pdfcrowd.crt

client_certificate_password

A password for PKCS12 file with a client certificate if it is needed.

Example:
  • PKCS12 certificate password: 123456

Tweaks

Expert options for fine-tuning output.

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:
Available for converters >= 20.10. See versioning.
Constraint:
  • The accepted range is 10-30.

converter_user_agent

Specifies the User-Agent HTTP header that will be used by the converter when a request is made to the converted web page.

Availability:
See versioning.
Default:
latest-chrome-desktop
Allowed Values:
  • chrome-desktop — The user-agent for desktop chrome corresponding to the converter used.
  • chrome-mobile — The user-agent for mobile chrome corresponding to the converter used.
  • latest-chrome-desktop — The user-agent of the recently released Chrome browser on desktops.
  • latest-chrome-mobile — The user-agent of the recently released Chrome browser on mobile devices.
  • custom string — A custom string for the user agent.
Examples:
  • Mimic the recent chrome on mobiles: latest-chrome-mobile
  • Mimic Safari 18.0 browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 14_7_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Safari/605.1.15