Skip to main content
This page builds one small PDF with each API. Both write a file and are awaited.

With the Doc API

Describe the document as content blocks, set role styles once, and call build.
1

Create a Doc

2

Set role styles

Styles assigned per role apply to every block of that type.
3

Add content

4

Build the file

The full script:

Explore the Doc API

Blocks, inline content, styling, fonts, formulas, tables, charts, and more.

With the Document API

Build elements with the page factories, then place them with page.add.
Page factories like page.text build an element but do not place it. Add what you build with page.add or a container’s add, or it will not render.

Explore the Document API

Elements, containers, layout, tables, themes, and positioning.

Choosing an API

Use Doc when

You are writing a document: a report, an article, an invoice. You want pagination, headers, and footers handled for you.

Use Document when

You need exact coordinates, custom layouts, overlapping elements, or per element control.