PDF API

Endpoint

POST /v1/pdf

Parameters

Input (one required)

ParameterTypeDefaultDescription
urlstringURL to convert to PDF
htmlstringRaw HTML to convert (max 5MB)

Paper Settings

ParameterTypeDefaultDescription
format"A4" | "Letter" | "Legal" | "Tabloid""A4"Paper format
landscapebooleanfalseLandscape orientation
margin.topstring"1cm"Top margin
margin.rightstring"1cm"Right margin
margin.bottomstring"1cm"Bottom margin
margin.leftstring"1cm"Left margin

Rendering

ParameterTypeDefaultDescription
print_backgroundbooleantrueInclude background colors/images
scalenumber (0.1-2.0)1.0Scale of the page rendering
page_rangesstringPage ranges (e.g., "1-5", "1,3,5")

Headers & Footers

ParameterTypeDefaultDescription
display_header_footerbooleanfalseShow header and footer
header_templatestringHTML template for the header
footer_templatestringHTML 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

ParameterTypeDefaultDescription
wait_for"load" | "networkidle" | "selector""load"When to capture
wait_selectorstringCSS selector to wait for
wait_timeoutnumber (1000-30000)30000Timeout in ms
response_type"binary" | "base64" | "url""binary"Response format
cache_ttlnumber (0-604800)86400Cache duration in seconds
no_cachebooleanfalseSkip 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