Render a PDF synchronously
Generate a PDF from one or more content sources and return it directly in the response. Content can be provided as URLs to fetch, raw HTML strings, or a combination of both. The response will contain the generated PDF file.
Body
Options for synchronous PDF rendering, where the PDF is returned directly in the API response.
An array of content parts to render into a single PDF. Each part can be a URL string, HTML content string, or a structured content object with type and content.
A content part that can be a URL string, HTML string, or a structured content object.
[
"https://example.com",
"<h1>Hello World</h1>",
{
"content": "<div>Structured HTML content</div>",
"type": "html"
}
]
Emulates the specified media type during rendering. Use 'screen' for web display styles or 'print' for print-optimized styles. Particularly useful for pages with different CSS for screen and print media queries.
screen
, print
Evaluates a JavaScript expression in the page context before rendering. Useful for manipulating the DOM, triggering actions, or waiting for dynamic content to load. If the expression returns a Promise, rendering will wait for it to resolve.
HTML template for the page footer. Supports special classes like 'date', 'title', 'url', 'pageNumber', and 'totalPages' for dynamic content.
HTML template for the page header. Supports special classes like 'date', 'title', 'url', 'pageNumber', and 'totalPages' for dynamic content.
Whether to include background images and colors in the rendered PDF. Set to false to optimize for printing or reduce file size.
Document margins specification with unit. Controls the space between the page edges and content.
{
"bottom": 10,
"left": 10,
"right": 10,
"top": 10,
"unit": "mm"
}
Page orientation for the PDF. 'portrait' is taller than wide, 'landscape' is wider than tall.
portrait
, landscape
Output file format. 'pdf/a' is PDF/A-2b compliant for archiving, while 'pdf' is standard PDF.
pdf/a
, pdf
Specifies which pages to include in the output using a comma-separated list of page ranges (e.g., '1-5, 8, 11-13'). Uses one-based indexing. Pages will be included in the document's natural order regardless of the specified range, and each page will only be included once. An empty string includes all pages.
Whether to prioritize page size defined in CSS using @page rules. When true, CSS page size takes precedence over the 'size' parameter. When false, content will be scaled to fit the specified paper size.
Whether to render the header and footer templates on each page. Must be true for header_template and footer_template to take effect.
Scale factor for the webpage rendering. Values below 1.0 reduce size, above 1.0 enlarge content.
0.1 <= x <= 2
Sets a cookie before rendering, useful for authenticated content or personalized views.
Standard document size preset name.
a0
, a1
, a2
, a3
, a4
, a5
, a6
, a7
, a8
, a9
, a10
, letter
, legal
, tabloid
, ledger
"a4"
Waits for a specific element attribute to be set before rendering, useful for ensuring dynamic content is fully loaded.
Specifies how the PDF should be encoded in the response. 'binary' returns raw bytes, while 'base64' returns a base64-encoded string.
binary
, base64
Response
Response from a synchronous render request, containing the generated PDF file.