PDF API
Endpoint
POST /v1/pdf
Parameters
| Parameter | Type | Default | Description |
|---|
url | string | — | URL to convert to PDF |
html | string | — | Raw HTML to convert (max 5MB) |
Paper Settings
| Parameter | Type | Default | Description |
|---|
format | "A4" | "Letter" | "Legal" | "Tabloid" | "A4" | Paper format |
landscape | boolean | false | Landscape orientation |
margin.top | string | "1cm" | Top margin |
margin.right | string | "1cm" | Right margin |
margin.bottom | string | "1cm" | Bottom margin |
margin.left | string | "1cm" | Left margin |
Rendering
| Parameter | Type | Default | Description |
|---|
print_background | boolean | true | Include background colors/images |
scale | number (0.1-2.0) | 1.0 | Scale of the page rendering |
page_ranges | string | — | Page ranges (e.g., "1-5", "1,3,5") |
| Parameter | Type | Default | Description |
|---|
display_header_footer | boolean | false | Show header and footer |
header_template | string | — | HTML template for the header |
footer_template | string | — | HTML template for the footer |
Header/footer templates support these classes:
.date — formatted print date
.title — document title
.url — document URL
.pageNumber — current page number
.totalPages — total pages
Wait & Response
| Parameter | Type | Default | Description |
|---|
wait_for | "load" | "networkidle" | "selector" | "load" | When to capture |
wait_selector | string | — | CSS selector to wait for |
wait_timeout | number (1000-30000) | 30000 | Timeout in ms |
response_type | "binary" | "base64" | "url" | "binary" | Response format |
cache_ttl | number (0-604800) | 86400 | Cache duration in seconds |
no_cache | boolean | false | Skip cache |
Example
curl -X POST https://api.rendershot.dev/v1/pdf \
-H "Authorization: Bearer sk_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com",
"format": "A4",
"margin": { "top": "2cm", "bottom": "2cm" },
"print_background": true
}' \
--output document.pdf
Generate PDF from HTML
curl -X POST https://api.rendershot.dev/v1/pdf \
-H "Authorization: Bearer sk_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"html": "<h1>Invoice #1234</h1><p>Amount: $99.00</p>",
"format": "Letter",
"display_header_footer": true,
"footer_template": "<div style=\"font-size:10px;text-align:center;width:100%;\">Page <span class=\"pageNumber\"></span> of <span class=\"totalPages\"></span></div>"
}' \
--output invoice.pdf