Generate invoice PDFs from HTML templates
Turn an HTML invoice template into a pixel-faithful PDF via API: template with your stack, style with CSS, POST to /v1/render. Example included.
Last updated
Invoices are the classic HTML→PDF workload: you already have the data, HTML+CSS is the easiest layout language you know, and the output must look identical every time. The pattern:
- Keep one
invoice.htmltemplate in your codebase (any template engine — Jinja2, ERB, Handlebars, Blade …). - Render it with the invoice data → an HTML string.
POST /v1/render→ store or email the returned PDF.
<style>
@page { size: A4; margin: 20mm;
@bottom-center { content: "Page " counter(page) " of " counter(pages); } }
table { width: 100%; border-collapse: collapse; }
td, th { padding: 6px 8px; border-bottom: 1px solid #ddd; }
.total { font-weight: bold; }
</style>
<h1>Invoice 2026-001</h1>
<table>
<tr><th>Item</th><th>Qty</th><th>Price</th></tr>
<tr><td>Design work</td><td>12 h</td><td>1,200.00 €</td></tr>
<tr class="total"><td>Total</td><td></td><td>1,200.00 €</td></tr>
</table>
Logos go in as data: URIs (how); the
rendering is deterministic — same HTML in, same PDF out.
Operational notes
Renders are synchronous and bounded (20 s timeout, 50 pages) — an invoice renders in well under a second, so you can generate it inline in the request that closes the order. One render costs one credit; a failed render (5xx) auto-refunds the credit. pdfrender stores nothing: the PDF exists only in the response.
Try it free
Paste your invoice template into the free browser tool, then try the API free — 100 renders a month, no card.
FAQ
- What is the best way to generate invoice PDFs from a web app?
- Render your existing HTML invoice template with the template engine you already use — Jinja2, ERB, Handlebars — then POST the finished HTML to /v1/render. The template stays in version control and is reviewed like the rest of your code.
- How do I get the invoice totals to line up across page breaks?
- Use CSS Paged Media: thead repeats automatically on each page, and break-inside: avoid on a row group keeps line items from splitting mid-row.
- Can I include a company logo?
- Yes, but it must be inlined as a data: URI. pdfrender never fetches external http(s) URLs, so a remote <img src> is rejected with 400 external_resource_blocked.