Joy DOM

Migrating from PDF

Mapping PDF concepts onto their Joy DOM equivalents.

PDF is fixed-page, binary, and read-mostly. Joy DOM is responsive, JSON, and editable. The translation is not always 1:1 - sometimes the Joy DOM equivalent is a different idea, not the same idea expressed differently. This page walks through the common mappings.

Concept map

PDF conceptJoy DOM equivalent
Pages (fixed size)One layout tree per document. Print breakpoints adjust for paper output.
Text framesp, h1h6, and span nodes.
Layout gridsNested div with flexDirection: "row" or "column" and gap.
Embedded fontsfontFamily in the spec; renderers ensure the font is available on the platform.
Tagged accessibility structureSemantic HTML-like node types (h1, p, etc.) inherit their accessibility role.
FormsCustom nodes (text-field, checkbox) registered with the renderer.
Bookmarks / outlineUse node ids and h1h6 headings; render the outline from the JSON.
Annotations / commentsOut of scope. Layer on top of the rendered document if your app needs them.
Print vs screenBreakpoint with { type: "type", value: "print" }.
Encryption / signingOut of scope. Sign or encrypt the JSON document at the transport layer.

A worked example

A typical PDF invoice has a fixed-page layout: 8.5"×11", absolute-positioned text frames, embedded fonts. The same invoice in Joy DOM:

  • Replace absolute-positioned text frames with nested div flex containers - see Invoice recipe.
  • Replace the fixed page size with a maxWidth on the outer container and let the renderer adapt the height.
  • Replace the embedded-font dependency with a fontFamily reference - the renderer resolves it on the platform.
  • Add a print breakpoint that tightens padding and drops the background colors for paper.

The JSON is shorter than the underlying PDF object stream, and it survives diffing in version control.

Things PDF does that Joy DOM does not (yet)

Honest limitations

Joy DOM is not a one-for-one PDF replacement. The list below is what Joy DOM does not currently match. Each is on the roadmap or explicitly out of scope.

  • Pixel-exact reproduction. PDFs are designed for archival fidelity; Joy DOM prioritizes responsive native rendering.
  • Embedded raster fonts. Renderers use platform fonts; embedding is not supported.
  • PDF/A archival profile. No archival profile exists yet.
  • Form data round-trip. Custom form-field components can capture input, but the protocol for persisting it is your renderer's job.

Generating a PDF from Joy DOM

For users who still need a PDF artifact:

  • Browser print preview ⇒ "Save as PDF" is the simplest path. Combine with your print breakpoint.
  • Headless browsers (Puppeteer, Playwright) point at a rendered Joy DOM page and call page.pdf().
  • A dedicated @joy-dom/pdf renderer is planned but not shipped.

Where next

On this page