Register your HTML layout via dashboard or API. At generation time, send just the template slug and variables — every PDF comes out with the same layout. Perfect for invoices, certificates, and contracts.
Send a variables object instead of full HTML on every request. Payload size drops by 10×–100×.
Update the template once and every subsequent generation reflects it. No client redeploy needed.
Syntax highlighting and live preview in the editor — non-engineers can update copy and layout safely.
| Use templates | Send raw HTML each time | |
|---|---|---|
| Request size | Hundreds of bytes – a few KB | Tens to hundreds of KB |
| Design change | One update in the dashboard | Redeploy client code |
| Best for | Recurring layouts (invoices, certs) | One-off dynamic reports |
| Non-engineer edits | Yes, via dashboard | No, requires a code change |
// Step 1: Register a template once via the dashboard or API
// (HTML body uses {{variable}} placeholders)
// Step 2: Generate a PDF by passing variables
const res = await fetch("/api/pdf/generate-from-template", {
method: "POST",
headers: { "Authorization": `Bearer ${API_KEY}` },
body: JSON.stringify({
template: "invoice",
variables: {
customer: "Acme Corp",
total: 12980,
items: [{ name: "Pro plan", amount: 12980 }],
},
}),
});