Expressions
Built-in Functions
REST API Endpoints
REST API Objects

# API

# Authorization

This endpoint requires an API token to be provided in the `Authorization` header of the request. The token should be provided using the `Bearer` scheme, like this:

For example, if the API token is `'my-api-token'`, the client would send the following header:

If a valid API token is not provided in the request, the endpoint will return a `401` error with the following response body:

Please contact the API administrator to obtain a valid API token.

# [version]/pdf

This endpoint takes a request with a handlebars template, CSS, and data in the request body, and uses the template and data to generate a PDF using puppeteer. The PDF can be customized using the optional `config` object in the request body.

Request body

The request body should include the following fields:

  • html: The handlebars template as a string.
  • css: The CSS styles to apply to the template as a string.
  • data: The data to use for rendering the template as a JSON object.
  • config: Optional PDF generation options as a JSON object (see below for details).

PDF options

The `config` object in the request body can be used to specify options for generating the PDF. This object should have the following format:

For more information about the available options, see the table in Print Config

Response

If the request is successful, the endpoint will return a PDF with a content-type of `application/pdf`. Otherwise, it will return an error message with a status code indicating the reason for the failure.

Property Type Description Default
displayHeaderFooter boolean (Optional) Whether to show the header and footer. false
footerTemplate string (Optional) HTML template for the print footer. Has the same constraints and support for special classes as headerTemplate.
format string (choice) (Optional)
  • Letter: 8.5in x 11in

  • Legal: 8.5in x 14in

  • Tabloid: 11in x 17in

  • Ledger: 17in x 11in

  • A0: 33.1in x 46.8in

  • A1: 23.4in x 33.1in

  • A2: 16.54in x 23.4in

  • A3: 11.7in x 16.54in

  • A4: 8.27in x 11.7in

  • A5: 5.83in x 8.27in

  • A6: 4.13in x 5.83in

letter.
headerTemplate string

(Optional) HTML template for the print header. Should be valid HTML with the following classes used to inject values into them:

- date formatted print date

- title document title

- url document location

- pageNumber current page number

- totalPages total pages in the document

height string | number (Optional) Sets the height of paper. You can pass in a number or a string with a unit.
landscape boolean (Optional) Whether to print in landscape orientation. = false
margin PDF Margin (Optional) Set the PDF margins. All elements are optional
Property Type
bottom string | number
left string | number
right string | number
top string | number
no margins are set.
omitBackground boolean (Optional) Hides default white background and allows generating pdfs with transparency. false
pageRanges string (Optional) Paper ranges to print, e.g. 1-5, 8, 11-13. The empty string, which means all pages are printed.
preferCSSPageSize boolean (Optional) Give any CSS @page size declared in the page priority over what is declared in the width or height or format option. false, which will scale the content to fit the paper size.
printBackground boolean (Optional) Set to true to print background graphics. false
scale number (Optional) Scales the rendering of the web page. Amount must be between 0.1 and 2. 1
width string | number (Optional) Sets the width of paper. You can pass in a number or a string with a unit.