Get an API Key Demo

HTML to PDF

Convert HTML into a downloadable PDF. Ideal for contracts, proposals, and reports.

POST/v1/pdf

Parameters

NameTypeDefaultDescription
html * String HTML to convert. Can be a full page or a fragment.
format String "A4" Page size: "A4", "A3", "Letter", "Legal".
landscape Boolean false Use landscape orientation.
margin String "20px" Margin applied to all four sides. Accepts any CSS length: "40px", "1in", "2cm".
variables Object {} Key-value pairs to replace {{key}} placeholders in the HTML before rendering.
ms_delay Integer 500 Extra wait in ms after page load. Max 30000.

Response

JSON
{
  "status":  "success",
  "pdf_url": "https://api.starkrender.com/static/uuid.pdf"
}

Examples

A4 proposal

JSON Body
{
  "html":   "<h1 style='font-family:Inter'>Commercial Proposal</h1><p>...</p>",
  "format": "A4",
  "margin": "40px"
}

A4 landscape — wide table report

JSON Body
{
  "html":      "<table>...</table>",
  "format":    "A4",
  "landscape": true,
  "margin":    "30px"
}

PDF with variable substitution

JSON Body
{
  "html":      "<h1>Contract for {{client_name}}</h1><p>Value: {{value}}</p>",
  "variables": { "client_name": "Acme Corp", "value": "R$ 50.000" },
  "format":    "A4",
  "margin":    "1in"
}

Notes

  • Print background colors and images are always preserved (print_background: true).
  • Fonts are detected and loaded automatically — same pipeline as HTML to Image.
  • The rendered PDF is multi-page if the content overflows the page height.
  • Use CSS @page { margin: 0; } inside your HTML to override the margin param per element.
On This Page
Parameters Response Examples Notes