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. The bigger your HTML, the more you save.
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 | Just the variables | The full HTML, every time |
| 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; values are plain strings)
// Step 2: Generate a PDF by passing variables
const res = await fetch("/api/pdf/generate-from-template", {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
template: "invoice",
variables: {
customer: "Acme Corp",
total: "12,980",
},
}),
});