HTML to PDF
Generate PDF from HTML Templates
Design your documents in HTML/CSS with Handlebars templating. Chromium renders them to pixel-perfect PDFs. Loops, conditionals, custom fonts, and locale-aware formatting included.
How it works
From HTML to PDF in three steps
Upload your template once, then generate as many PDFs as you need with different data.
Upload your HTML template
Upload an HTML file with Handlebars syntax — {{variables}}, {{#each}} loops, {{#if}} conditionals. Design with CSS including Flexbox, Grid, and custom fonts.
Send your data as JSON
POST your template ID and a JSON data object. Handlebars merges the data into your template, then Chromium renders it to a pixel-perfect PDF.
Download rendered PDF
Get a signed download URL for the rendered PDF. Set page size and margins in the options.
Integration
Generate an invoice PDF
Send your template ID and data as JSON. Handlebars merges the data, Chromium renders the PDF.
curl -X POST https://api.pdfforge.dev/v1/documents/generate \ -H "Authorization: Bearer pk_live_your_key" \ -H "Content-Type: application/json" \ -d '{ "template_id": "tpl_invoice", "data": { "company": "Acme Corp", "invoice_number": "INV-2026-042", "items": [ { "name": "API Pro Plan", "amount": 49.00 }, { "name": "Extra Documents", "amount": 12.50 } ] }, "options": { "format": "A4" } }'
Benefits
Why developers choose PDFForge for HTML to PDF
Real Chromium rendering, Handlebars templating, and a simple REST API. No servers to manage.
Chromium pixel-perfect rendering
Your HTML is rendered by a real Chromium browser — the same engine behind Google Chrome. CSS Grid, Flexbox, web fonts, and media queries all work exactly as expected.
Handlebars templating
Use {{#each items}} for loops, {{#if condition}} for conditionals, and built-in helpers for formatting dates, numbers, and currencies.
Page size and margins
Choose A4, A3, Letter, or Legal. Set margins in mm, cm, in, or px. Control exactly how your document looks on paper.
Multiple pages
CSS page-break-before and page-break-after control pagination. Generate invoices, reports, and multi-page documents with ease.
Locale-aware formatting
Built-in Handlebars helpers for dates, numbers, and currencies. Use {{formatCurrency amount "EUR" "fr-FR"}} syntax with explicit locale and currency arguments.
Comparison
PDFForge vs. alternatives
FAQ
Frequently asked questions
Yes, using base64 data URIs. Include @font-face declarations with base64-encoded font data in your HTML template. External font URLs (including Google Fonts) are blocked for security. Use WOFF2 format encoded as base64 for best results.
Headers and footers are not yet supported but are on our roadmap. For now, include header and footer content directly in your HTML template body using CSS for positioning and styling.
Yes, using base64 data URIs. Images must be embedded as base64 data URIs in your HTML: use <img src="data:image/png;base64,..."> format. External image URLs are blocked for security to prevent SSRF attacks.
Absolutely. PDFForge uses a full Chromium browser for rendering, so all modern CSS features work: Grid, Flexbox, custom properties, calc(), clamp(), media queries, and more. If it works in Chrome, it works in PDFForge.
There is no hard page limit. Most documents generate in 1-5 seconds. Very large documents (100+ pages) may take longer. If you need to generate extremely long documents regularly, contact us about custom plans with higher limits.
PDFForge includes built-in helpers: formatDate for dates (e.g., {{formatDate date "fr-FR" "long"}}), formatNumber for numbers (e.g., {{formatNumber value "en-GB" 2}}), formatCurrency for currencies (e.g., {{formatCurrency amount "EUR" "fr-FR"}}), and now for the current date (e.g., {{now "en-GB"}}). Comparison helpers (eq, gt, lt, and, or, not) and math helpers (add, multiply) are also available. All locale and currency arguments are passed explicitly.
Yes. Set landscape: true in the options. For page size, choose from A4, A3, Letter, or Legal. Custom dimensions are on our roadmap.
PDFForge uses Chromium internally, similar to Puppeteer. The difference is that PDFForge is a managed service — you do not need to install Chromium, manage browser instances, handle memory leaks, or scale your infrastructure. You send HTML + data, we return a PDF.
Ready to generate your first document?
Start free with 50 documents per month. No credit card required. Up and running in under 5 minutes.