You probably don't need Chromium to make a PDF
The default advice for "generate a PDF" is HTML-to-PDF via headless Chromium
(Puppeteer/Playwright). For arbitrary web pages, fine. For a document with a
known layout — an invoice, a receipt, a statement — it's the wrong tool:
- ~300MB of Chromium to ship and keep patched
- system libraries that break on minimal/serverless images
- seconds of cold-start on the first request
-
--no-sandboxfoot-guns and memory tuning
For structured documents you need correct layout and correct math, not a
browser.
The lighter approach: render straight from data
InvoicePDF takes JSON and returns a PDF — no browser involved:
curl -X POST https://invoicepdf-app.azurewebsites.net/invoice \
-H "Content-Type: application/json" \
-d '{"number":"INV-1","currency":"USD","seller_name":"Me LLC",
"buyer_name":"Acme Corp",
"items":[{"description":"Consulting","quantity":8,"unit_price":120}],
"tax_rate_percent":10}' \
--output invoice.pdf
Under the hood it's fpdf2 — pure Python, no system deps — so it starts
instantly, sips memory, and hosts on a free tier like a static app.
Bonus: get the money math right
Never use floats for money (0.1 + 0.2 != 0.3). Keep amounts as integer minor
units (cents) and format at the very end, so $27.00 + 10% tax is exactly
$29.70. InvoicePDF does this internally.
Try it
- Live playground: https://invoicepdf-app.azurewebsites.net
- Sample PDF: https://invoicepdf-app.azurewebsites.net/sample
- Open source (MIT): https://github.com/rahulatrkm/invoicepdf
If you've been reaching for headless Chromium to make invoices, this is a much
lighter path. Feedback welcome.
Top comments (0)