Puppeteer alternative
Puppeteer for PDFs, without the Chrome
If you use Puppeteer to turn HTML into PDFs, Forme renders the same HTML and print CSS in-process — no headless browser to install, launch, sandbox, or keep warm. It replaces the PDF half of Puppeteer, not the browser-automation half.
import { renderHtml } from '@formepdf/html';
// Same HTML. No browser, no subprocess.
const { pdf, warnings } = await renderHtml(html);~20ms typical render for a 6-page report, vs ~1-5s with Chrome boot.
0 browser dependencies — nothing to apt-get, no sandbox flags.
Honest benchmarks, including where a warm Puppeteer wins on very large tables.
Side by side
The same job, before and after
Rendering HTML
import puppeteer from 'puppeteer';
// Requires Chrome installed, Docker config,
// 200MB binary, sandbox flags...
const browser = await puppeteer.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox'],
executablePath: process.env.CHROME_PATH });
const page = await browser.newPage();
await page.setContent(html, { waitUntil: 'networkidle0' });
const pdf = await page.pdf({ format: 'A4' });
await browser.close();import { renderHtml } from '@formepdf/html';
// Same HTML. No browser, no subprocess.
const { pdf, warnings } = await renderHtml(html);Repeating headers and page numbers
/* Guess and check. Sometimes works. */
@media print {
.header { position: fixed; top: 0; }
/* Hope the browser repeats it... */
}
.table-row { page-break-inside: avoid; }@page {
margin: 72pt 54pt;
@top-center { content: "ACME WIDGET CO."; }
@bottom-right { content: counter(page); }
}
@page :first { @top-center { content: none; } }
h2 { break-before: page; }Deployment
FROM node:20
# Install Chrome dependencies (500MB+)
RUN apt-get update && apt-get install -y \
chromium fonts-liberation \
--no-install-recommends
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromiumnpm install @formepdf/html
# WASM runs anywhere: Node, Bun, Deno,
# Cloudflare Workers, Vercel Edge, Lambda,
# and the browser. Zero native dependencies.Comparison
Forme vs Puppeteer for PDF generation
| Feature | Forme | Puppeteer |
|---|---|---|
| Runs without a browser | Yes (WASM, in-process) | No (headless Chrome) |
| Print CSS: @page, margin boxes, counters | Yes, incl. @page :first | Partial (no margin boxes) |
| Page breaks | Page-native layout (widows/orphans) | CSS page-break (fragile) |
| Table headers | Automatic on every page | Inconsistent <thead> |
| Render speed | ~20ms (6-page report) | ~1-5s (Chrome boot) |
| Memory | No browser process (WASM) | ~50-200MB |
| PDF/A archival conformance | PDF/A-2, A-3, A-4/A-4f — veraPDF-verified, composes with PDF/UA-1 and UA-2 | No (Chrome print output isn't PDF/A) |
| Redaction, merging, certification | Built in: redactText(), mergePdfs(), certifyPdf() | No |
| Execute page JavaScript, screenshots, scraping | No — not a browser | Yes |
Measured per document and per runtime on a fixed corpus. See the benchmarks →
Be honest about scope
When Puppeteer is still the right tool
Your PDF depends on page JavaScript
If the document is assembled by scripts running in the page — charts drawn on a canvas at runtime, client-side data fetching — you need a browser. Forme renders HTML and CSS, not a running page.
You need screenshots or scraping
Puppeteer automates a whole browser. Forme replaces the PDF output, not navigation, clicking, or capture.
You rely on full browser CSS
Forme implements a documented subset and warns by name on anything outside it. Check the subset table against your templates first.
Checked against 15 real templates from GitHub: 14 render correctly, 1 degrades with its cause named, 0 broken. How it was measured →
Migration
Moving off Puppeteer in four steps
- 01
Install the HTML engine
One package, no system libraries.
npm install @formepdf/html - 02
Swap the render call
Replace
launch,newPage,setContent, andpdfwith one call. Keep your HTML as it is.import { renderHtml } from '@formepdf/html'; // Same HTML. No browser, no subprocess. const { pdf, warnings } = await renderHtml(html); - 03
Read the warnings
renderHtmlreturns awarningsarray naming any CSS outside the supported subset, and any render defect where the engine had to compromise. Fix those, and nothing is silently dropped. - 04
Move print layout into @page
Replace fixed-position headers and footers with
@top-centerand@bottom-rightmargin boxes andcounter(page).
Puppeteer migration questions
- Is Forme a drop-in Puppeteer alternative?
- For document rendering, largely yes — you pass HTML and get bytes back. What differs is scope: Puppeteer automates a whole browser, so if you depend on running JavaScript in the page, screenshotting live sites, or scraping, Forme does not replace that. It replaces the PDF half, without the Chrome half.
- Will my existing HTML render the same?
- Most templates do. Forme was graded against Chrome print on 15 production templates from GitHub: 14 rendered correctly and 1 degraded legibly with its cause named. Anything outside the supported CSS subset is reported by name in the warnings.
- Is Forme faster than Puppeteer?
- For typical documents, yes: ~20ms for a 6-page report versus ~1-5s including Chrome boot. A warm Puppeteer can win on very large tables; the published benchmarks show both.
- Can I run it on serverless or the edge?
- Yes. Forme is WASM, verified in real workerd as well as Node, so it runs on Cloudflare Workers, Vercel Edge, and AWS Lambda without a Chromium layer.