Advanced Options – Headless Chrome

For the Headless Chrome 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 headless chrome.

Sample Payload with Advanced Options


    {
        "html": "Hello World",
        "options": {
            "landscape": true
        }
    }
Attribute Type Description
landscape Boolean Paper orientation. Defaults to false.
displayHeaderFooter Boolean Display header and footer. Defaults to false.
printBackground Boolean Print background graphics. Defaults to false.
scale Number Scale of the webpage rendering. Defaults to 1.
width Number Paper width in inches. Defaults to 8.27 inches.
height Number Paper height in inches. Defaults to 11.69 inches.
marginBottom Number Bottom margin in inches. Defaults to 1cm (~0.4 inches).
marginLeft Number Left margin in inches. Defaults to 1cm (~0.4 inches).
marginRight Number Right margin in inches. Defaults to 1cm (~0.4 inches).
marginTop Number Top margin in inches. Defaults to 1cm (~0.4 inches).
pageRanges String Paper ranges to print, e.g., ‘1-5, 8, 11-13’. Defaults to the empty string, which means print all pages.
ignoreInvalidPageRanges Boolean Whether to silently ignore invalid but successfully parsed page ranges, such as ‘3-2’. Defaults to false.
headerTemplate String HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: –

 

  • date: formatted print date
  • title: document title
  • url: document location
  • pageNumber: current page number
  • totalPages: total pages in the document

For example, <span class=”title”></span> would generate span containing the title.

footerTemplate String HTML template for the print footer. Should use the same format as the `headerTemplate`.
preferCSSPageSize Boolean Whether or not to prefer page size as defined by css. Defaults to false, in which case the content will be scaled to fit the paper size.

Version 2.0.0

v2 of API2PDF adds more functionality at endpoint v2.api2pdf.com.

Attribute Type Description
delay Integer The amount of time to wait for the page to render before taking screenshot or PDF (in milliseconds). Defaults to 0.
puppeteerWaitForMethod String Acceptable values are WaitForNavigation, WaitForExpression, WaitForFunction, WaitForSelector. See more details here.
puppeteerWaitForValue String Proper value for the method in the puppeteerWaitForMethod. For WaitForNavigation, the only acceptable values are domcontentloaded, load, networkidle0, networkidle2.
omitBackground bool Transparent background on PDF