Skip to main content
A sheet names a template by its id and gives the field values.

Import

Example

Notes

  • The default template is registered, unless seedDefault is false.
  • register() replaces a template that has the same id.
  • get() returns undefined for an unknown id.
  • Template geometry is in paper millimetres.
  • The registry is not saved in the project file. Give it again when you export, through the templates option.
  • A value saved in the title block wins over the automatic value for projectName, date, sheetName and scale. An empty saved value prints the automatic value. pageNumber and pageCount are always counted.
  • The automatic revision field shows the code of the last entry of the sheet’s revisions. A sheet with no revisions prints the saved value. The default template prints it as “Rev:”.
  • A revisionTable annotation lists the sheet’s revisions as a table: Rev, Date and Description, one row each, oldest first.
  • The automatic scale is the scale that all viewports of the sheet share. When their scales differ, it is “As indicated”.
  • An image in a title block or on a sheet can be a PNG, a JPEG or an SVG data URL. The PDF draws an SVG as vector paths. It draws path (arcs included), line, polyline, polygon, rect (rounded too), circle, ellipse, text and g, and refuses other SVG elements, an unreadable data URL and an image over 1 MB by name.

Stable template elements

normalizeTitleblockTemplate(value: unknown): NormalizedTitleblockTemplate validates and detaches a template. Legacy elements may omit id; normalization assigns deterministic IDs. Keep the normalized resource when editing: insertions require an authored ID, and removing or changing another element preserves every remaining ID. Duplicate IDs, unknown fields, invalid geometry and invalid typography are rejected. TitleblockRegistry.register normalizes and detaches its input. Store each accepted template as an immutable resource version and retain the versions referenced by undo history. The strict project file stores the sheet’s templateId, not the registry. Save the resource definitions and embedded PNG/JPEG logo data with the project; normalize and register those definitions again before preview or export after reopening.
NormalizedTitleblockTemplate has the same shape as TitleblockTemplate, with a required id on every element. Geometry remains relative to the template origin in paper millimetres. Field name, auto and label retain their bindings; customization never replaces them with resolved text. Export preserves the resolved geometry and values; editable identities remain in the saved resource definitions. Inheritance: implements TitleblockTemplateRegistry

Constructor

Methods

register

get

resolveTitleblock

Resolve a template + instance + context to absolute paper-mm drawables.

fitTitleblockField

Set a resolved title-block field inside its box, as a title block does: at its own height when the value fits on one line, else wrapped by words, then shrunk towards its minimum height until the lines fit the box’s height.

normalizeTitleblockTemplate

DEFAULT_TITLEBLOCK_ID

DEFAULT_TITLEBLOCK_TEMPLATE

A bottom-right A-series title block that works out of the box: project name, sheet name, the current revision, an editable sheet number, ISO date, scale, and page x/of y.

Types

TitleblockTemplateRegistry

The package does not export this type by name.

TitleblockTemplate

A reusable title-block: static graphics + named fields, authored once and placed via a TitleblockInstance (.spec/debt.md “Paper / drawing layer”).
string
required
string
required
{ width: number; height: number; }
required
Block size in paper units (mm).
'bottom-right' | 'bottom' | 'right' | 'top' | 'free'
required
{ x: number; y: number; }
Absolute paper-mm origin, for anchor: "free". Ignored otherwise.
TitleblockElement[]
required

TitleblockContext

Inputs used to compute auto-fields when resolving a title block. The package does not export this type by name.
PageSpec
required
string
required
string
number
number
string
Pre-formatted scale label, e.g. “1:50”.
string
ISO date (YYYY-MM-DD). Defaults to today.
string
The current revision code of the sheet: the code of its last revisions entry.

ResolvedTitleblock

A title block resolved to absolute paper-mm drawables. The package does not export this type by name.

ResolvedText

The package does not export this type by name.
string
string
required
Rect
required
number
required
number
The smallest height the field shrinks to; see TitleblockField.minFontSize.
'left' | 'center' | 'right'
required

FittedTitleblockField

A title-block field set inside its box: the text height it is set at and its lines.
number
required
The height every line is set at, before the style’s typography scale.
TitleblockFieldLine[]
required

NormalizedTitleblockTemplate

A validated, detached title-block template in which every element has its own id.

TitleblockElement

ResolvedStatic

The package does not export this type by name.

TitleblockFieldLine

One line of a fitted title-block field, at its baseline, in paper mm.

TitleblockStatic

The package does not export this type by name.
string
'line' | 'rect' | 'image'
required
Rect
required
Relative to the block origin (top-left). line runs corner→corner.
string
string
string

TitleblockField

The package does not export this type by name.
string
'field'
required
string
required
Bound by name from TitleblockInstance.values, unless auto is set.
TitleblockAutoField
Rect
required
Relative to the block origin (top-left).
number
required
number
The smallest height, in paper mm, the field shrinks to when its value does not fit its box at fontSize, after wrapping by words. Absent: 1.8 mm, or fontSize when that is smaller.
'left' | 'center' | 'right'
string
Optional caption drawn before the value.

TitleblockAutoField

The package does not export this type by name.
Last modified on November 30, 2026