Inkspan › Guides › HTML to PDF API
Turn any HTML string into a pixel-faithful PDF. No Chromium in your container, no font installs, no scaling headaches — POST your HTML and stream back a PDF.
Because rendering uses CSS paged media rather than a browser screenshot, headers, footers, and page counters work the way print CSS says they should.
import requests
r = requests.post(
'https://api.inkspan.dev/v1/generate/html',
headers={'X-API-Key': 'ink_live_...'},
json={
"html": "<h1>Invoice INV-1042</h1><p>Total: $61.00</p>"
},
)
r.raise_for_status()
with open('document.pdf', 'wb') as f:
f.write(r.content)
| Name | Type | Required | Description |
|---|---|---|---|
html | string | yes | The HTML document or fragment to render. |
filename | string | no | Filename in the response's Content-Disposition. Defaults to document.pdf. |
Returns a PDF as a binary stream with Content-Type: application/pdf and Content-Disposition: attachment; filename=document.pdf. Write the response body straight to disk — do not parse it as JSON.
https:// URLs, or inline them as data: URIs.@page { size: A4; margin: 18mm; } in your HTML to control them.file:// URLs are rejected. Host assets publicly or inline them.| Status | Meaning | Fix |
|---|---|---|
401 | Invalid or missing API key | Send your key in the X-API-Key header. |
402 | Monthly quota exceeded | The response reports used/quota. Upgrade at inkspan.dev/#pricing. |
422 | Missing or invalid parameter | Check required fields in the table above — the body names the offending field. |
Failed requests do not count against your quota; only successful ones are metered.
Yes — 100 documents a month, no card required. Usage-based plans start at $19/month when you outgrow it.
Send your key in the X-API-Key header on every request.
No. Only successful requests are metered.
Get a free API key →Full guides for /v1/generate/html: cURL · Python · Node.js · all guides