Import
Example
Notes
- The default template is registered, unless
seedDefaultisfalse. register()replaces a template that has the same id.get()returnsundefinedfor 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
templatesoption. - A value saved in the title block wins over the automatic value for
projectName,date,sheetNameandscale. An empty saved value prints the automatic value.pageNumberandpageCountare always counted. - The automatic
revisionfield shows thecodeof the last entry of the sheet’srevisions. A sheet with no revisions prints the saved value. The default template prints it as “Rev:”. - A
revisionTableannotation lists the sheet’srevisionsas 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,textandg, 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 aTitleblockInstance (.spec/debt.md “Paper / drawing layer”).
TitleblockContext
Inputs used to compute auto-fields when resolving a title block. The package does not export this type by name.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.FittedTitleblockField
A title-block field set inside its box: the text height it is set at and its lines.NormalizedTitleblockTemplate
A validated, detached title-block template in which every element has its ownid.
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.TitleblockField
The package does not export this type by name.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.