Building a native PDF engine in Rust
How PressJet turns print HTML and JSON into paginated PDFs, measures fidelity, and gives developers and agents layout feedback they can act on.
I previously wrote about rendering PDFs with Puppeteer on Vercel. It is a useful approach when you already have a web page and need Chrome to print it. Building PressJet started with a different workload. I wanted an application to send invoice or contract data and get predictable pagination, along with enough feedback to understand why a table or heading landed where it did.
A one-page invoice made the project look easy. The cases that shaped the engine had repeated table headers, paragraphs crossing page boundaries, and rows that could grow after a customer changed the data.
Two inputs, one layout engine
PressJet accepts a typed JSON document tree or a supported subset of print HTML and CSS. The HTML compiler produces the same kind of document tree as JSON. From there, the renderer measures text and boxes, chooses page breaks, then paints text, images, and vector paths into a PDF.
That shared boundary lets me verify behaviors that matter to both interfaces. A repeated header should stay with the table body. A paragraph rule should still hold when the next record is much longer. The browser playground uses the same rendering model through WebAssembly. Native applications can use the CLI or the HTTP service.
Browser rendering is useful for a template editor. The user can change a value and preview the document where they are working. The first export still has to load and compile the module, so I measure it separately from later renders. I also keep the server-side signing workflow separate from the in-browser preview.
Benchmark the document you would actually ship
One fixture compares the same print HTML for a 47-page synthetic lease. PressJet produced it in 116.2 ms median HTTP time and Gotenberg in 405.6 ms on the recorded run. That test used seven measured requests after warm-up on one pinned logical CPU. The numbers describe this fixture and configuration.
When comparing renderers, I check page count, where each page starts, and extracted text alongside latency. A fast output that drops a clause or shifts a signature block is a failed migration. The benchmark repository includes the test documents, method, and raw resource measurements.
Give the caller a way to repair a layout
The same layout engine can report findings with a path to the affected node. A report that points to a particular box, line, or missing glyph is useful in a developer's terminal. It is also useful to a coding agent calling the CLI or MCP. The agent can revise the offending part of a template and check again. Once the template passes review, application data can fill it repeatedly without another model call.
The signing pilot picks up where rendering ends. Participants review the agreement and record their acceptances. After the final acceptance, the workflow seals the finished PDF and makes the signed evidence available alongside it.
Try a template in the browser · Read the rendering documentation · See the agent workflow