HTML → PDF document

PDF Generation API

POST your own HTML — with your data already merged in — and get a print-ready PDF back. Built for invoices, receipts, certificates and reports: page size, margins, orientation, print backgrounds, and header/footer templates with page numbers.

POST /v1/pdf with a JSON body of { html } renders your markup in a real headless Chromium and returns the PDF bytes. No page to host, no browser to run — you generate the HTML (server-side templating, your invoice engine, an LLM), we turn it into a document. Pass url instead to render a live page.

Try it

request
curl -X POST "https://api.rasterly.dev/v1/pdf" \
  -H "X-Api-Key: sk_live_..." \
  -H "content-type: application/json" \
  -d '{
    "html": "<h1>Invoice #1042</h1><p>Amount due: <b>$249.00</b></p>",
    "format": "A4",
    "margin": "0.5in",
    "footer_html": "<div style=font-size:9px;width:100%;text-align:center>Page <span class=pageNumber></span> of <span class=totalPages></span></div>"
  }' \
  -o invoice.pdf
response — application/pdf
# the raw PDF bytes — A4, print backgrounds on, footer page numbers
%PDF-1.4 …  → invoice.pdf

Body options

What it's for

Why rasterly

PDF generation is the same one-render engine as the screenshot and extract endpoints — one browser process reused across requests, so a warm render is about a second of CPU. That's why it's priced from $0.90 per 1,000 documents with 100/mo free, instead of a per-seat "document platform" subscription.

FAQ

Can I send my own HTML, or only a URL?
Both. POST a JSON body with html to render markup you generate server-side (an invoice, a certificate) with no page to host, or pass url to render a live page to PDF. Raw HTML is the common case for document generation.
Can I add headers, footers and page numbers?
Yes. Pass header_html and footer_html using Chromium's print template syntax — e.g. a running title in the header and a page number (the pageNumber / totalPages spans) in the footer. Set page size with format, orientation with landscape, and spacing with margin.
Do CSS, images, web fonts and backgrounds work?
Yes — the HTML renders in a real headless Chromium, so your CSS, remote images and @font-face web fonts load, and CSS print backgrounds are on by default (turn them off with print_background:false). Use @page and @media print for full control.
How is this different from the screenshot PDF option?
GET /v1/screenshot?format=pdf snapshots a live URL. POST /v1/pdf is built for document generation: it takes the HTML you produce (with your data merged in) plus page size, margins and header/footer templates, and returns a print-ready document.
Start free — 100 renders Try the live demo