About this endpoint
What it does
Renders HTML, Markdown or a web page to a PDF in Chromium. Set the page layout, headers and footers, watermark, password and document properties, and pick how the PDF comes back.
Request Body
| Parameter | Type | Description |
|---|---|---|
| html | String | Required if markdown and url are not set. Raw HTML to render. Max length 1500000 characters. Provide exactly one of html, markdown or url. |
| markdown | String | Required if html and url are not set. Markdown to convert to HTML and render. Max length 1500000 characters. |
| url | String | Required if html and markdown are not set. Public web page to load and render. Must be http or https. |
| response_mode | String | How the PDF is returned. Allowed values: binary, base64, json, url. Default: binary. |
| filename | String | Name of the PDF. Default: document.pdf. Max length 255 characters. |
| page_format | String | Paper size, for example A4 or Letter. Default: A4. |
| page_size | String | Paper size name, if different from page_format. Max length 32 characters. |
| width | String | Custom page width, as pixels or a CSS unit (for example 800px, 21cm). Overrides page_format. |
| height | String | Custom page height, as pixels or a CSS unit. |
| landscape | Boolean | Render in landscape orientation. Default: false. |
| scale | Number | Render scale. Typical range 0.1 to 2. Default: 1. |
| margin_top | String | Top margin as a CSS length, for example 1cm or 10mm. Default: 1cm. |
| margin_bottom | String | Bottom margin. Default: 1cm. |
| margin_left | String | Left margin. Default: 1cm. |
| margin_right | String | Right margin. Default: 1cm. |
| print_background | Boolean | Print CSS background colours and images. Default: true. |
| prefer_css_page_size | Boolean | Use the page size from CSS @page when the page sets one. Default: false. |
| page_ranges | String | Pages to keep, for example 1-3,5. Max length 64 characters. |
| media_type | String | CSS media type to emulate. Allowed values: screen, print. Default: screen. |
| header_template | String | HTML printed at the top of every page. |
| footer_template | String | HTML printed at the bottom of every page. |
| auto_page_numbers | Boolean | Add page numbers to every page. Default: false. |
| page_number_template | String | Page number text. Default: {{page}} / {{totalPages}}. Max length 128 characters. |
| page_number_alignment | String | Page number position. Allowed values: left, center, right. Default: center. |
| page_number_color | String | Page number colour as hex. Default: #444444. |
| page_number_font_size | String | Page number font size. Default: 10px. |
| watermark_text | String | Text stamped on every page. Max length 1024 characters. |
| watermark_font_size | Integer | Watermark text size. Range: 1 to 500. Default: 40. |
| watermark_color | String | Watermark text colour as hex. Default: #000000. |
| watermark_opacity | Number | Watermark text opacity. Range: 0 to 1. Default: 0.15. |
| watermark_rotation | Integer | Watermark text angle in degrees. Range: 0 to 360. Default: 45. |
| watermark_position | String | Watermark position, for example center, top-left or bottom-right. Default: center. |
| watermark_image_url | String | Public URL of an image stamped on every page. Max length 2048 characters. |
| watermark_image_scale | Number | Image watermark size factor. Range: 0.1 to 10. Default: 1. |
| watermark_image_opacity | Number | Image watermark opacity. Range: 0 to 1. Default: 0.15. |
| watermark_image_rotation | Integer | Image watermark angle in degrees. Range: 0 to 360. Default: 45. |
| password | String | Password needed to open the PDF. Max length 20 characters. |
| compress | Boolean | Compress embedded images. Default: false. |
| compression_level | ENUM | How strongly to compress when compress is true. Allowed values: low, medium, high. Default: medium. |
| compress_quality | Integer | Image quality after compression. Range: 30 to 95. |
| title | String | Document title property. Max length 100 characters. |
| author | String | Document author property. Max length 100 characters. |
| subject | String | Document subject property. Max length 100 characters. |
| keywords | String Array | Document keywords property. |
| creator | String | Document creator property. Max length 100 characters. |
| producer | String | Document producer property. Max length 100 characters. |
| custom_metadata | Object | Extra key/value properties to write into the PDF. |
| custom_css | String | CSS injected into the page before rendering. |
| style_url | String | Public URL of a CSS file to load before rendering. Max length 2048 characters. |
| script_url | String | Public URL of a JavaScript file to load before rendering. |
| scripts | String Array | Inline scripts or script URLs to run before rendering. |
| execute_javascript | Boolean | Run the page's JavaScript before rendering. Default: true. |
| sanitize_html | Boolean | Clean the HTML before rendering. Can remove scripts and styles. Default: false. |
| wait_until | ENUM | When the page counts as loaded. Allowed values: load, domcontentloaded, networkidle, networkidle0, networkidle2. Default: networkidle. |
| wait_for_selector | String | CSS selector to wait for before rendering. Max length 256 characters. |
| wait_for_function | String | JavaScript expression to wait for until it is true. |
| wait_for_timeout | Integer | How long to wait for the selector or function, in milliseconds. Range: 0 to 300000. |
| timeout | Integer | Load and render timeout in milliseconds. Range: 1000 to 180000. Default: 30000. |
| auth_type | ENUM | Login used when loading url. Allowed values: none, basic, bearer. Default: none. |
| auth_credentials | String | Login value for auth_type: username:password for basic, the token for bearer. Max length 2048 characters. |
| extra_headers | Object | Extra HTTP headers sent when loading url. |
| cookies | Object Array | Cookies set in the browser before loading the page. |
Response
Returns the PDF in the shape set by response_mode. In json mode, returns a JSON object with the file and its metadata.
| Parameter | Type | Description |
|---|---|---|
| filename | String | Name of the PDF. |
| size | Integer | Size of the PDF in bytes. |
| created_at | String | UTC timestamp when the file was created. |
| pdf_base64 | String | Base64-encoded PDF. |
Notes
- Provide exactly one of
html,markdownorurl. binaryreturns the PDF file itself, not JSON.base64returns onlyfilenameandpdf_base64.urlreturnsfile_url,expires_atandexpires_in_seconds. The link needs no authentication and stops working after it expires.- The request body must be under 5 MB. Larger bodies return
413. - A render that runs past
timeoutreturns504. url,style_url,script_url,scriptsandwatermark_image_urlmust be public addresses.



