pdg XML → PDF

A tiny, deterministic XML → PDF engine

Print without
a browser.

A small layout engine that typesets PDFs from XML — no headless Chrome, no 300 MB image. Describe the document; get the same bytes on every run, from any language.

Render from Ruby Node Python Rails the browser

Try it — the document is computed, not drawn
XML source
Rendered

This invoice isn't laid out by hand — it's computed. The line items, the tax, and the total all fall out of the data block at the top, looped into markup. And it's typeset by the real engine: the same Rust that writes your PDFs, compiled to WebAssembly and running in this tab. Change a number and the whole page re-typesets — open it in the playground to fork and share a link.

Render from your stack

The engine ships as a package for your language — the native binary is bundled in, so there's nothing to install at runtime — and as inlined WebAssembly for the browser. Feed it your XML, get PDF bytes back (or the engine's diagnostics if something's off). Same engine, same bytes, everywhere.

Why pdg
The idea

The whole engine,
in one question.

“Given this much space —
how much of you fits?”

Every element answers it. Ask recursively and text wrapping, column balancing, tables, and clean page breaks all fall out of the single rule — no special cases, no escape hatches. Three honest stages: parselayoutrender.

  • Fits

    The element lays itself out and reports the height it used.

  • Partly fits

    It takes what it can, then hands the remainder back to continue on the next page.

  • Doesn't fit

    It defers; the parent moves it whole to the next page. Nothing is clipped, ever.

The vocabulary

A dozen elements, learnable in an afternoon — block structure, inline markup, page furniture, and a style: box model that rides on any of them. No cascade to fight, no specificity wars: what you write is what lands on the page. Open the full reference