--- layout: home title: Forma for Effect PDF description: Declarative typed documents and invoices in a Forma prelude. Check document, page, section, and table structure with typed data bindings before anything renders. sidebar: false aside: false pageClass: forma-index forma-effect-pdf ---

Forma for Effect PDF · pre-alpha exploration

Typed documents and invoices, checked before they render.

Invoices, statements, and compliance packets combine layout trees with structured business data—usually held together by untyped templates and headless browser glue. @forma/effect-pdf is a pre-alpha Forma prelude that defines document, page, section, and table with checked data bindings. Prelude checking and IR projection run live in the browser sandbox today; PDF generation and live Preview Portal rendering are planned.

(document invoice :data Invoice
  (page :size :letter
    (section :title "Summary" …)
    (table   :rows  :lines   …)))
   │
   │  read → project → check → IR
   ▼
Canonical Document IR  (checked today)
   └─→ Preview Portal & PDF  (planned)

Pre-alpha exploration · live Preview Portal rendering is planned · open sandbox

00 The problem

Broken invoices shouldn't be discovered by a customer.

Document pipelines usually scatter schema definitions, HTML templates, and PDF rendering scripts across separate layers. Rename a field on an invoice record or mistype a table column, and the template renders undefined or a blank total. Forma makes document structure and data bindings part of one checked tree, so mismatches fail at the line you wrote.

  1. doc.tsx<Document title={…}>← root contractdocument
  2. page.tsx<Page size="LETTER">← sheetpage
  3. header.tsx<Section>{invoice.customer}</Section>← blocksection
  4. lines.tsxrows.map(r => <Row … />)← bound rowstable

Document vocabulary

(document / page / section / table)

Sandbox · Checked prelude

Layout and data bindings checked together.

In the sandbox, @forma/effect-pdf defines document, page, section, and table as ordinary prelude forms. Each form declares its allowed children, page options, and typed data bindings.

Because document trees are pure declarations, they cannot perform ambient I/O or fetch records mid-render. All data enters through explicit typed bindings, and the compiler projects the verified tree into canonical Document IR.

src/invoice.lispexploratory prelude sketch
```lisp fragment (type LineItem {:sku String :qty Int :unit-cents Int}) (type Invoice {:number String :customer String :lines (List LineItem) :total-cents Int}) (document customer-invoice :data Invoice (page :size :letter (section :title "Bill To" :bind :customer) (table :rows :lines :columns [:sku :qty :unit-cents]) (section :title "Total Due" :bind :total-cents))) ```

Preview & rendering

Live Preview Portal rendering is planned.

Planned

What runs today vs. what comes next.

Today, the Effect PDF sandbox runs Forma's real typechecker over src/invoice.lisp and the mounted @forma/effect-pdf prelude. You can edit bindings, test diagnostics, and modify prelude descriptors with copy-on-write overrides.

Live Preview Portal rendering—turning the checked Document IR into a visual page preview and downloadable PDF bytes inside the browser—is planned, not yet implemented. The sandbox includes the Preview Portal shell to show where live rendering plugs into the checked IR pipeline.

03 Architecture

Pure document trees, decoupled from the renderer.

Separating checked structure from PDF byte emission keeps templates small, reviewable, and portable across renderers.

Pure layout descriptors

document, page, section, and table are prelude forms with explicit slot types and child contracts—no arbitrary scripts inside layout.

Checked data bindings

Bindings connect sections and table columns to declared schemas so missing fields and wrong types are caught before rendering.

Canonical Document IR

Every passing document projects to structured IR that a future TypeScript or Effect PDF renderer can consume without re-parsing Lisp.

Editable prelude

Open @forma/effect-pdf in the sandbox file tree to see how each document form is defined and customize it live.

04 Limits

What you give up, and what is not built yet.

This is a pre-alpha exploration of declarative document modeling. Most of a real PDF stack sits outside it today.

Trade-offs

  • Constrained layout vocabulary. Four structural forms cover invoices and statements well, not arbitrary editorial design or complex CSS grids.
  • No inline logic in templates. Formatting helpers and data preparation happen in typed functions before the document tree sees them.
  • Exploratory surface. Form slots and IR shapes are early prototypes and may change without compatibility guarantees.

Missing today

  • No PDF renderer or TS emitter yet. The sandbox checks structure and projects IR; it does not emit PDF bytes or runnable TypeScript yet.
  • Live Preview Portal rendering is planned. Visual page rendering and interactive sample-data previews are not implemented yet.
  • No pagination or typography engine. Page breaks, widow/orphan control, font embedding, and localization formatting remain future renderer work.

05 Fit

When to try it.

Worth trying

  • Exploring typed document IR and schema-checked invoice layouts in Forma.
  • Prototyping domain-specific document forms (receipts, statements, reports) by editing the sandbox prelude.
  • Studying how pure templates can feed an Effect-managed rendering pipeline.

Not yet

  • Generating production PDFs or customer-facing invoices today.
  • Replacing React-PDF, Typst, LaTeX, or headless-Chromium pipelines now.
  • Teams that need live visual previews or pagination control immediately.

Check the invoice structure in your browser.

Open the Effect PDF sandbox to edit src/invoice.lisp, break a binding, and inspect the @forma/effect-pdf prelude descriptors directly.