PDF Generation API
Generate professional PDFs from a template and a data payload — invoices, certificates, reports, and formal letters. Headless Chrome renders the HTML and returns a permanent PDF URL. No layout tools, no design skills required.
How it works
- POST a template name and your document data
- Browserless renders the HTML template with print-optimised CSS
- PDF uploads to the 1FRX CDN (Cloudflare R2)
- Returns a permanent PDF URL in under 3 seconds
Request
Endpoint: POST /api/pdf-gen
Requires: X-1FRX-Key header
Parameters
| Parameter | Type | Description |
|---|---|---|
template |
string, required | "invoice", "certificate", "report", "letter", or "custom" |
data |
object, required | Template variables — see template fields below |
html |
string | Raw HTML — only when template is "custom" |
page_size |
string, optional | "A4" (default), "Letter", "Legal" |
landscape |
boolean, optional | Landscape orientation — auto-set for certificate template |
margin |
string, optional | "none", "small", "normal" (default), "large" |
Example request
curl -X POST https://api.1frx.com/v1/pdf-gen \
-H "X-1FRX-Key: sk_live_your_key" \
-H "Content-Type: application/json" \
-d '{
"template": "invoice",
"data": {
"company_name": "Acme Ltd",
"company_address": "12 Baker Street, London W1U 3BT",
"company_email": "billing@acme.com",
"client_name": "Widget Corp",
"client_address": "99 High Street, Manchester M1 1AB",
"invoice_number": "INV-2024-0042",
"invoice_date": "2024-03-15",
"due_date": "2024-04-15",
"currency": "GBP",
"line_items": [
{ "description": "Web Design Services", "quantity": 1, "unit_price": 2500 },
{ "description": "SEO Audit", "quantity": 1, "unit_price": 750 }
],
"tax_rate": 20,
"brand_color": "#5ee3ff"
}
}'
Response
{
"success": true,
"url": "https://assets.1frx.com/pdfs/b7d3e9f2.pdf",
"template": "invoice",
"page_size": "A4",
"landscape": false,
"pages_est": 1,
"size_bytes": 87432
}
Template field reference
Invoice fields
company_name, company_address, company_email, company_logo (URL), client_name, client_address, client_email, invoice_number, invoice_date (YYYY-MM-DD), due_date, currency (default: USD), line_items (array of {description, quantity, unit_price}), tax_rate (%), discount (amount), notes, brand_color
Certificate fields
recipient_name, title (default: "Certificate of Completion"), course_name, issued_by, issued_date, signatory_name, signatory_title, description, brand_color, logo_url. Note: always renders in landscape.
Report fields
title, subtitle, author, date, company_name, logo_url, brand_color, sections (array of {heading, body, bullets[]})
Letter fields
sender_name, sender_address, sender_email, recipient_name, recipient_title, recipient_company, recipient_address, date, subject, body (use double newlines for paragraphs), closing (default: "Yours sincerely"), company_name, logo_url, brand_color
Batch generation tip
To generate PDFs in bulk (e.g. 500 certificates), call /api/pdf-gen in parallel requests. Each call is independent. Combine with Zapier or Make to trigger from a spreadsheet row or form submission.
Custom HTML
When template is "custom", provide your own full HTML string. Use print-optimised CSS (avoid fixed viewport units). Background colours are always preserved.