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:
Authorization: Bearer [token]
For example, if the API token is `'my-api-token'`, the client would send the following header:
Authorization: Bearer my-api-token
If a valid API token is not provided in the request, the endpoint will return a `401` error with the following response body:
Unauthorized
Please contact the API administrator to obtain a valid API token.
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.
The request body should include the following fields:
The `config` object in the request body can be used to specify options for generating the PDF. This object should have the following format:
{
"format": "Letter", // The page size (defaults to "Letter")
"margin": { // The page margins (defaults to 0)
"top": "1in",
"right": "1in",
"bottom": "1in",
"left": "1in"
},
"printBackground": true, // Whether to print the background color and image (defaults to false)
"landscape": false // Whether to generate the PDF in landscape orientation (defaults to false)
}
For more information about the available options, see the table in Print Config
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 .
|
||||||||||
headerTemplate | string |
(Optional) HTML template for the print header. Should be valid HTML with the following classes used to inject values into them: -
-
-
-
-
|
|||||||||||
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
|
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. |