99.95% uptime • 42M documents generated • P95 render time 680ms
PDF Generation API
Still fighting pixel shifts, missing fonts, and "works on my machine" PDFs in production? Ship consistent, print-ready documents from HTML or JSON—rendered server-side, versioned, and auditable—so your team stops babysitting exports and starts shipping features.
Need format-specific engines? Explore Word to PDF and Excel to PDF.
Live preview: generate → download
// cURL: HTML → PDF
curl -X POST "https://api.xspdf.com/v1/pdf" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"html": "<html><body><h1>Invoice #1842</h1><p>Paid</p></body></html>",
"page": { "format": "A4", "margin": "12mm" },
"assets": { "waitForFonts": true },
"output": { "filename": "invoice-1842.pdf" }
}'
// Response: { "id":"pdf_9n3...", "status":"ready", "url":"https://..." } Median render time
412ms
For standard invoices & reports
Failed render rate
0.08%
Retry + deterministic builds
Security posture
SOC 2-ready controls
Encryption in transit + at rest
Throughput
1.8M PDFs / day
Autoscaling render fleet
Time saved
47 min/dev/day
Less PDF firefighting
Output quality
Print-ready by default
Fonts, margins, links intact
You know the feeling when the PDF "works"… until it hits production
The first invoice looks fine. Then a customer in Germany opens it in a different viewer and the layout breaks. Your support team pings engineering. Engineering pings DevOps. DevOps pings you.
CSS roulette
A minor CSS change "somewhere else" shifts pagination. Suddenly page 2 starts mid-table.
Font + asset drift
One missing font file and your "brand PDF" becomes a generic fallback—quietly, expensively.
Debugging without certainty
No reproducible builds, no audit trail—just "try again" and hope the PDF looks right.
The real cost isn't the PDF. It's the engineering attention tax: every broken render steals roadmap time, creates release risk, and makes "document generation" feel like a trap you can't refactor out of.
There's a better way: a deterministic document generation API
Send HTML (for pixel-perfect layouts) or JSON (for template-driven consistency). Get back a signed URL or stream bytes. Every render is traceable, repeatable, and built for production workloads.
- 1
Choose your input: HTML or JSON
HTML gives full layout control; JSON keeps business data separate from presentation.
- 2
Render with locked dependencies
Fonts, CSS, and assets resolve predictably—no surprises when you deploy.
- 3
Deliver PDFs your customers trust
Clickable links, correct pagination, stable tables, and print-ready output.
JSON → template → PDF
Predictable. Testable. Auditable.
POST /v1/pdf
Authorization: Bearer $API_KEY
{
"templateId": "tpl_invoice_v3",
"data": {
"invoiceNumber": "1842",
"customer": { "name": "Northwind GmbH" },
"items": [
{ "name": "Pro Plan", "qty": 1, "price": 19900 }
],
"totals": { "currency": "EUR", "amount": 19900 }
},
"pdf": {
"format": "A4",
"printBackground": true,
"taggedPdf": true
},
"webhooks": {
"onComplete": "https://yourapp.com/webhooks/pdf"
}
} The "CTO test"
If it can't be versioned, load-tested, and rolled back safely, it's not infrastructure. This pdf generator API is built like a core service—not a side script.
Production features that prevent "PDF incidents"
The best document generation API is the one you rarely have to think about—because it quietly handles the failure modes you've already lived through.
Deterministic renders
Same input → same output. Stop chasing "random" layout shifts across environments.
Pagination you can trust
Stable page breaks, headers/footers, and tables that don't split in embarrassing places.
Brand-true typography
Embed fonts and assets reliably so every PDF looks like your product—not a template.
Fast at peak traffic
Low-latency rendering with queueing + retries so spikes don't become outages.
Versioned templates
Change layouts safely: roll forward for new docs, keep old versions for audit & reprints.
Flexible delivery
Stream bytes, return a URL, or push via webhook—whatever fits your architecture.
One decision that pays you back every sprint
Every hour you don't spend debugging PDFs is an hour you can spend on onboarding, billing, reporting, and the product your customers actually notice. Don't let "document generation" quietly become your most expensive background task.
FAQ: what developers ask before they commit
If you're evaluating this as core infrastructure, these are the questions that matter—latency, reliability, control, and escape hatches.
Can I generate PDFs from both HTML and structured data (JSON)?
Yes. Use HTML when you need full layout freedom (marketing one-pagers, complex invoices). Use JSON + templates when you want repeatable structure (statements, receipts, reports) and safer change management. Many teams start with HTML and migrate high-volume documents to templates for stability.
How do you prevent "broken PDFs" from deploys and CSS changes?
By treating rendering like builds: version templates, lock assets (fonts/CSS), and keep renders reproducible. You can ship a new template version for new documents without breaking reprints of older ones—so the "invoice from last month" stays identical.
What about converting existing Office docs instead of rebuilding templates?
If your source-of-truth is already Office, you'll move faster with dedicated conversion pillars: Word to PDF for DOC/DOCX workflows and Excel to PDF for spreadsheet-driven reports. For product-native documents (invoices, receipts, statements), API-driven generation is typically more stable and testable long-term.
Is it safe to use for sensitive documents?
Sensitive docs are the reason to use an API instead of ad-hoc scripts. Use TLS for transport, restrict API keys, and store outputs with signed, time-limited URLs. If you need stricter controls, keep payloads minimal (template + data), and return PDFs via direct streaming so you control storage and retention.
Stop maintaining PDFs. Start generating them.
Replace brittle exports with a PDF generation engine you can rely on: predictable renders, versioned templates, and performance that holds under load. Start free in minutes—then scale when your product (and your customers) demand it.
- ✓ No credit card required to start
- ✓ Signed URLs + webhook delivery
- ✓ HTML + JSON workflows
- ✓ Built for CTO-level reliability
Start generating in under 5 minutes
Copy, paste, render. If you can call an API, you can ship PDFs today.
Urgency, without pressure: the longer you wait, the more "PDF edge cases" you'll ship into your backlog.