Use case
Invoice PDF API
Generate professional invoice PDFs programmatically. Send HTML and get a PDF back in under a second — no headless browser to manage, no Puppeteer dependency to maintain.
Why use an API instead of a library?
No server overhead
Puppeteer and wkhtmltopdf consume significant memory per instance. Papyr handles the Chromium cluster — your server stays lean.
Consistent output
Local Chromium versions drift across developer machines and staging/production environments. One API means one renderer.
Under 1 second
Managed Chromium instances with a concurrency queue. No cold start on your server, no waiting for the browser to launch.
Generate an invoice PDF
Send your invoice HTML and receive a PDF binary. The example below generates a simple invoice with line items and a total.
curl -X POST https://api.getpapyr.dev/v1/render/pdf \
-H "Authorization: Bearer pk_live_..." \
-H "Content-Type: application/json" \
-d '{
"html": "<html><body style=\"font-family:sans-serif;padding:40px\">
<h1 style=\"font-size:28px;margin-bottom:4px\">Invoice #1042</h1>
<p style=\"color:#666\">Due: January 31, 2026</p>
<table style=\"width:100%;border-collapse:collapse;margin-top:24px\">
<tr style=\"border-bottom:2px solid #eee\">
<th style=\"text-align:left;padding:8px 0\">Description</th>
<th style=\"text-align:right;padding:8px 0\">Amount</th>
</tr>
<tr><td style=\"padding:12px 0\">Development — 40hrs</td>
<td style=\"text-align:right\">$4,000.00</td></tr>
<tr><td style=\"padding:12px 0\">Design review</td>
<td style=\"text-align:right\">$800.00</td></tr>
<tr style=\"border-top:2px solid #eee;font-weight:bold\">
<td style=\"padding:12px 0\">Total</td>
<td style=\"text-align:right\">$4,800.00</td></tr>
</table>
</body></html>",
"options": { "format": "A4", "margin": { "top": "20mm", "bottom": "20mm" } }
}'const response = await fetch("https://api.getpapyr.dev/v1/render/pdf", {
method: "POST",
headers: {
"Authorization": "Bearer pk_live_...",
"Content-Type": "application/json",
},
body: JSON.stringify({
html: buildInvoiceHtml(invoice), // your HTML template function
options: {
format: "A4",
margin: { top: "20mm", right: "20mm", bottom: "20mm", left: "20mm" },
},
}),
});
const pdf = await response.arrayBuffer();
// Save to disk, return to user, or upload to S3import httpx
response = httpx.post(
"https://api.getpapyr.dev/v1/render/pdf",
headers={"Authorization": "Bearer pk_live_..."},
json={
"html": build_invoice_html(invoice), # your HTML template function
"options": {
"format": "A4",
"margin": {"top": "20mm", "right": "20mm",
"bottom": "20mm", "left": "20mm"},
},
},
)
pdf_bytes = response.content
# Save to disk, return to user, or upload to S3Common invoice patterns
Save to cloud storage
Pipe the PDF binary directly to S3, GCS, or R2. No temp files needed — stream the response body straight to your upload client.
Email as attachment
Convert the response to a Buffer or Blob and attach it to your email (Resend, SendGrid, Nodemailer). Typical invoice PDF is 50–200KB.
Return to browser for download
Set Content-Type: application/pdf and Content-Disposition: attachment; filename=invoice-1042.pdf on your API response. The browser triggers a download.
Store in your database
For audit trails or regeneration, store the raw PDF bytes in a BYTEA (Postgres) column or as a base64-encoded string alongside the invoice record.
Pricing
Start generating invoice PDFs
100 free invoices per month. No credit card required. API key in 30 seconds.