Private betav0.1.0
Docs
Format developer documentation

Document

The outermost container, holding every Layout and an optional Numbering config.

A Document is the root of the tree that Format renders into a PDF. Everything you author lives inside it: the Layouts that describe each page and the Flows whose content paginates across them. It also carries the PDF's metadata: the title, subject, author, and keywords.

Fields

NameTypeDescription
titleRequired
stringThe document title. Written to the rendered PDF as its title metadata and used in the Format Dashboard for filtering and reporting.
subject
stringThe document subject. Written to the rendered PDF as its subject metadata.
author
stringThe document author. Written to the rendered PDF as its author metadata.
keywords
stringComma-separated keywords. Written to the rendered PDF as its keyword metadata and used in the Format Dashboard for filtering and reporting.
fontMode
stringThe font strategy from <Document fonts>, either "compact" or "fidelity". Carried through verbatim with no default applied, and omitted entirely when unset.

Example

A minimal document. One Layout, one Flow, one rendered page.

export const doc = () => (
  <Document title="Invoice #1234" author="Acme Co.">
    <Layout id="invoice" width={793.71} height={1122.52}>
      <Flow>
        <p>Hello, world.</p>
      </Flow>
    </Layout>
  </Document>
)
<template>
  <Document title="Invoice #1234" author="Acme Co.">
    <Layout id="invoice" :width="793.71" :height="1122.52">
      <Flow>
        <p>Hello, world.</p>
      </Flow>
    </Layout>
  </Document>
</template>
<template data-type="document" data-title="Invoice #1234" data-author="Acme Co.">
  <template data-type="layout" data-id="invoice" data-width="793.71px" data-height="1122.52px">
    <template data-type="flow">
      <p>Hello, world.</p>
    </template>
  </template>
</template>

Usage

Document is the root container, and there is exactly one. Set its title (required) plus any of subject, author, and keywords to populate the rendered PDF's metadata, then nest your Layouts inside.

If your codebase produces several distinct PDFs, each compiles to its own Document (one per entry point). You can't render two Documents in a single render call.

What goes inside

Two kinds of children sit directly inside a Document:

  • Layouts. Page designs that produce pages. At least one, otherwise nothing renders. Each Layout holds the Flows that paginate its content.
  • A Numbering config. An optional <Numbering> block sets the document-wide counter style for headings, figures, and footnotes. At most one.

Each Layout produces its own run of pages in source order, so a Document with two Layouts renders the first run, then the second.

PDF metadata

The title, subject, author, and keywords fields map to the rendered PDF's metadata block.

Was this page helpful?