> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ploterr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# TitleblockRegistry

> TitleblockRegistry holds your title block templates.

A sheet names a template by its id and gives the field values.

## Import

```typescript theme={null}
import {
  TitleblockRegistry,
  resolveTitleblock,
  DEFAULT_TITLEBLOCK_ID,
  DEFAULT_TITLEBLOCK_TEMPLATE,
} from '@opengeometry/floorkit';
```

## Example

```typescript theme={null}
import {
  TitleblockRegistry,
  DEFAULT_TITLEBLOCK_ID,
  DEFAULT_TITLEBLOCK_TEMPLATE,
} from '@opengeometry/floorkit';

const templates = new TitleblockRegistry();
const standard = templates.get(DEFAULT_TITLEBLOCK_ID);
const custom = { ...DEFAULT_TITLEBLOCK_TEMPLATE, id: 'office-titleblock' };
templates.register(custom);
console.log(standard, templates.get('office-titleblock'));
```

## 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.

**Inheritance:** `implements TitleblockTemplateRegistry`

## Constructor

```typescript theme={null}
constructor(seedDefault?: boolean);
```

## Methods

### register

```typescript theme={null}
register(template: TitleblockTemplate): void;
```

### get

```typescript theme={null}
get(id: string): TitleblockTemplate | undefined;
```

## resolveTitleblock

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

```typescript theme={null}
function resolveTitleblock(
  template: TitleblockTemplate,
  instance: TitleblockInstance,
  context: TitleblockContext,
): ResolvedTitleblock;
```

## DEFAULT\_TITLEBLOCK\_ID

```typescript theme={null}
const DEFAULT_TITLEBLOCK_ID = 'default';
```

## DEFAULT\_TITLEBLOCK\_TEMPLATE

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

```typescript theme={null}
const DEFAULT_TITLEBLOCK_TEMPLATE: TitleblockTemplate;
```

## Types

### TitleblockTemplateRegistry

The package does not export this type by name.

```typescript theme={null}
interface TitleblockTemplateRegistry {
  register(template: TitleblockTemplate): void;
  get(id: string): TitleblockTemplate | undefined;
}
```

### TitleblockTemplate

A reusable title-block: static graphics + named fields, authored once and placed via a `TitleblockInstance` (.spec/debt.md "Paper / drawing layer").

```typescript theme={null}
interface TitleblockTemplate {
  id: string;
  name: string;
  size: {
    width: number;
    height: number;
  };
  anchor: 'bottom-right' | 'bottom' | 'right' | 'top' | 'free';
  origin?: {
    x: number;
    y: number;
  };
  elements: TitleblockElement[];
}
```

<ResponseField name="id" type="string" required />

<ResponseField name="name" type="string" required />

<ResponseField
  name="size"
  type="{
width: number;
height: number;
}"
  required
>
  Block size in paper units (mm).
</ResponseField>

<ResponseField name="anchor" type="&#x22;bottom-right&#x22; | &#x22;bottom&#x22; | &#x22;right&#x22; | &#x22;top&#x22; | &#x22;free&#x22;" required />

<ResponseField
  name="origin"
  type="{
x: number;
y: number;
}"
>
  Absolute paper-mm origin, for `anchor: "free"`. Ignored otherwise.
</ResponseField>

<ResponseField name="elements" type="TitleblockElement[]" required />

### TitleblockContext

Inputs used to compute auto-fields when resolving a title block.

The package does not export this type by name.

```typescript theme={null}
interface TitleblockContext {
  page: PageSpec;
  sheetName: string;
  projectName?: string;
  pageNumber?: number;
  pageCount?: number;
  scale?: string;
  date?: string;
}
```

<ResponseField name="page" type="PageSpec" required />

<ResponseField name="sheetName" type="string" required />

<ResponseField name="projectName" type="string" />

<ResponseField name="pageNumber" type="number" />

<ResponseField name="pageCount" type="number" />

<ResponseField name="scale" type="string">
  Pre-formatted scale label, e.g. "1:50".
</ResponseField>

<ResponseField name="date" type="string">
  ISO date (YYYY-MM-DD). Defaults to today.
</ResponseField>

### ResolvedTitleblock

A title block resolved to absolute paper-mm drawables.

The package does not export this type by name.

```typescript theme={null}
interface ResolvedTitleblock {
  statics: ResolvedStatic[];
  texts: ResolvedText[];
}
```

### TitleblockElement

```typescript theme={null}
type TitleblockElement = TitleblockStatic | TitleblockField;
```

### ResolvedStatic

The package does not export this type by name.

```typescript theme={null}
interface ResolvedStatic {
  kind: 'line' | 'rect' | 'image';
  rect: Rect;
  stroke?: string;
  fill?: string;
  src?: string;
}
```

### ResolvedText

The package does not export this type by name.

```typescript theme={null}
interface ResolvedText {
  text: string;
  rect: Rect;
  fontSize: number;
  align: 'left' | 'center' | 'right';
}
```

### TitleblockStatic

The package does not export this type by name.

```typescript theme={null}
interface TitleblockStatic {
  kind: 'line' | 'rect' | 'image';
  rect: Rect;
  stroke?: string;
  fill?: string;
  src?: string;
}
```

<ResponseField name="kind" type="&#x22;line&#x22; | &#x22;rect&#x22; | &#x22;image&#x22;" required />

<ResponseField name="rect" type="Rect" required>
  Relative to the block origin (top-left). `line` runs corner→corner.
</ResponseField>

<ResponseField name="stroke" type="string" />

<ResponseField name="fill" type="string" />

<ResponseField name="src" type="string" />

### TitleblockField

The package does not export this type by name.

```typescript theme={null}
interface TitleblockField {
  kind: 'field';
  name: string;
  auto?: TitleblockAutoField;
  rect: Rect;
  fontSize: number;
  align?: 'left' | 'center' | 'right';
  label?: string;
}
```

<ResponseField name="kind" type="&#x22;field&#x22;" required />

<ResponseField name="name" type="string" required>
  Bound by name from `TitleblockInstance.values`, unless `auto` is set.
</ResponseField>

<ResponseField name="auto" type="TitleblockAutoField" />

<ResponseField name="rect" type="Rect" required>
  Relative to the block origin (top-left).
</ResponseField>

<ResponseField name="fontSize" type="number" required />

<ResponseField name="align" type="&#x22;left&#x22; | &#x22;center&#x22; | &#x22;right&#x22;" />

<ResponseField name="label" type="string">
  Optional caption drawn before the value.
</ResponseField>

### Rect

Rectangle in paper units (mm).

The package does not export this type by name.

```typescript theme={null}
interface Rect {
  x: number;
  y: number;
  width: number;
  height: number;
}
```

### TitleblockAutoField

The package does not export this type by name.

```typescript theme={null}
type TitleblockAutoField =
  | 'pageNumber'
  | 'pageCount'
  | 'date'
  | 'scale'
  | 'sheetName'
  | 'projectName';
```

## Related

* [`PageSpec`](/floorkit/api/drawings/sheet-documents#pagespec)
* [`TitleblockInstance`](/floorkit/api/drawings/sheet-documents#titleblockinstance)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.