Reference

Document

Root of a PDF document: the paper, the margins and what the file says about itself.

Document(page_size: Enum, size: String, landscape: Bool, …) { … }

Before 5.0

PDF

page_size

A4

A3

A5

Letter

Legal

landscape

No preview for this one: the example below shows how it is written.

Example

wf

Document(size: "A4", margin: 56, title: "Invoice INV-2041", author: "Northwind Ltd", subject: "Invoice", keywords: "invoice, november", lang: "en") { Header { Text("Northwind Ltd · Invoice INV-2041").muted.sm.right } Footer { Text("Northwind Ltd · 12 Harbour Street · Bristol").muted.sm.center } Heading("Invoice INV-2041").h1 Text("Issued 17 November 2026 · Due in 30 days").muted Table(caption: "Items") { Table.Head { Table.Row { Table.Cell("Item") Table.Cell("Amount") } } Table.Body { Table.Row { Table.Cell("Design review") Table.Cell("€1,200.00") } Table.Row { Table.Cell("Hosting, November") Table.Cell("€90.00") } } } Text("Total: €1,290.00").bold.right }

Landscape Letter, by flag

wf

Document(title: "Quarterly figures").Letter.landscape { Heading("Quarterly figures").h1 }

Props

Props of Document
PropTypeUnsetMeaning

page_size:

one of its cases

A4

The paper, as a case (also written size:, which takes more); unset, the config's page_size under build.pdf. Written as a flag, .A4, or by name, page_size: .A4.

  • .A4 (the default): 210 × 297 mm
  • .A3: 297 × 420 mm
  • .A5: 148 × 210 mm
  • .Letter: 8.5 × 11 in
  • .Legal: 8.5 × 14 in

size:

String

A4

The paper: A3–A6, B5, Letter, Legal, Tabloid, Executive, or a width and a height, 210mm 297mm (a bare number is pt); unset, the config's page_size under build.pdf

landscape:

Bool

false

Turn the paper on its side, its longer edge across; landscape: false keeps it upright. Written as a flag, .landscape, or landscape: true.

margin:

Number or String

72pt each

The page margins: one length, or two to four as CSS writes them (72, 20mm 25mm); a bare number is pt; unset, the config's build.pdf.margins

title:

String

the page's title

The file's title, shown by a reader in place of its name

author:

String

none

The file's author; several separated by commas

subject:

String

none

What the document is about: the file's description

keywords:

String

none

Comma-separated keywords

lang:

String

meta.lang

The document's language (en, ar): the file's language, and ar, he, fa or ur lays it out right to left

Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.

Flags and cases

A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.

.A4

.A3

.A5

.Letter

.Legal

.landscape

Events

Every element also takes the props, the events and the attribute families listed on every element.

Slots

children

Renders with the class wf-document, stable across releases, so a stylesheet may target it.

These controls list the props' cases; the example below shows them written.