# Annotations

The author written into every comment, Acrobat's shared-review rule for the Comments panel, and the lists every picker offers: colors, highlighter and note colors, line weights, mark sizes, border styles and line endings. The annotation tools and the Comments panel's editing need a license that includes `annotations`.

- Interface: `AnnotationsConfig`
- Config path: `config.annotations`

## Example

```ts
annotations: {
  author: session.user.displayName,
  palette: [
    { color: '#0B3D91', label: 'Brand navy' },
    { color: '#E03C31', label: 'Brand red' },
    '#1F2937',
  ],
  highlightColors: ['#FFF59D', '#C5E1A5'],
  strokeWidths: [1, 2, 3],
}
```

## Options (9)

### `author`

- Type: `string`
- Default: `'' (none)`
- Page: https://kernstra.com/docs/web-sdk/config/annotations/author

Written into each comment as its author: notes, highlights, text boxes, drawings, shapes, stamps, replies and statuses. The note composer shows the author's name and initials at the top, and the name is stored on every note, highlight, text box, drawing, shape and stamp the user adds, and on every reply and status, where every other reader shows it as the author. Empty, the composer reads "You" and the note carries only its text and color, so a host that does not know who is signed in gives nothing away by accident.

```ts
const viewer = new PDFViewer(container, doc, {
  annotations: { author: session.user.displayName },
});
```

### `ownCommentsOnly`

- Type: `boolean`
- Default: `false`
- Page: https://kernstra.com/docs/web-sdk/config/annotations/owncommentsonly

Acrobat's shared-review rule: the Comments panel edits and deletes only the author's own comments (those whose stored author matches `author`); anyone replies and sets a status. Off, as in Acrobat on an ordinary file, anyone edits or deletes any comment that is not Locked. The API is your code and is not held to it.

### `palette`

- Type: `ColorList`
- Default: `the SDK's twelve`
- Page: https://kernstra.com/docs/web-sdk/config/annotations/palette

Every color picker's swatches — shapes, drawing, text, and the highlighter's picker beyond its own row. The SDK's twelve are black, graphite, red, orange, amber, green, teal, blue, indigo, violet, pink and white. Shapes start in the palette's first color when it leaves out the SDK's default ink; new text starts in pure black, or in your palette's first color when your own palette leaves black out.

### `highlightColors`

- Type: `ColorList`
- Default: `yellow, green, blue, pink`
- Page: https://kernstra.com/docs/web-sdk/config/annotations/highlightcolors

The highlighter's own row. Highlights — from the Highlight tool, Mark text or the selection bar, whichever is used first — start in the first of `highlightColors` when yellow is not in it.

### `noteColors`

- Type: `ColorList`
- Default: `yellow, green, blue, pink`
- Page: https://kernstra.com/docs/web-sdk/config/annotations/notecolors

A sticky note's colors.

### `strokeWidths`

- Type: `readonly number[]`
- Default: `0.5, 1, 2, 4, 6`
- Page: https://kernstra.com/docs/web-sdk/config/annotations/strokewidths

Line weights (pt) for drawing and shapes. Sorted and de-duplicated. Shapes start at the listed weight nearest 2 pt.

### `markSizes`

- Type: `readonly number[]`
- Default: `12, 16, 20, 28, 40`
- Page: https://kernstra.com/docs/web-sdk/config/annotations/marksizes

The Marks tools' sizes (pt): a tick, a cross, a dot. A form's box is 10–14 pt, a checklist's 20. Sorted and de-duplicated.

### `borderStyles`

- Type: `readonly BorderStyle[]`
- Default: `'solid', 'dashed', 'dotted', 'cloudy'`
- Page: https://kernstra.com/docs/web-sdk/config/annotations/borderstyles

The drawing bar's Style picker, in order. `BorderStyle` is `'solid' | 'dashed' | 'dotted' | 'cloudy'`; a cloud goes only round a rectangle, ellipse or polygon. `[]` hides the picker, and every shape is drawn solid.

### `lineEndings`

- Type: `readonly LineEnding[]`
- Default: `all ten`
- Page: https://kernstra.com/docs/web-sdk/config/annotations/lineendings

The Line and Arrow tools' Ends picker, in order (any of `'none'`, `'square'`, `'circle'`, `'diamond'`, `'openArrow'`, `'closedArrow'`, `'butt'`, `'rOpenArrow'`, `'rClosedArrow'`, `'slash'` — see [`LineEnding`](https://kernstra.com/docs/web-sdk/api/types#ty-lineending)). `[]` hides the picker, and each tool keeps its own caps.

## Notes

**The shapes.** `ColorList` is `readonly (string | ColorOption)[]`. A `ColorOption` is `{ color: string; label: string }`: `color` is `'#rgb'` or `'#rrggbb'`, stored and written as `'#RRGGBB'`; `label` is what the color is called — tooltip and screen-reader name — and empty means the hex.

**Your own colors.** The color lists are ink: they are written into the document, so they do not follow the theme. A bare hex is named by itself for screen readers; give a `ColorOption` to name it in your users' language. The built-in colors are named from the string table (`color.*`, `ink.*`).

**An invalid entry is skipped.** A value that is not a hex color is skipped with a console warning, and a list with nothing valid left keeps the default — a picker is never empty. Each dropped value is reported once per page as `[Kernstra] <option>: ignoring <value>` (for example, `[Kernstra] annotations.palette: ignoring "teal"`). An eraser value that has to be corrected is reported only if you set it yourself. A color listed twice (`#f00` and `#FF0000` are the same) is shown once. Weights and sizes are sorted and de-duplicated the same way.

**A tool starts on your lists**: shapes in the palette's first color when it leaves out the SDK's default ink, and at the listed weight nearest 2 pt; new text in pure black, or in your palette's first color when your own palette leaves black out; highlights in the first of `highlightColors` when yellow is not in it. A color the user picks is kept.

A viewer reads the picker lists once, when it is built; to change them, build a new viewer (see [Locale](https://kernstra.com/docs/web-sdk/config/locale) for what a rebuild keeps).


Web page: https://kernstra.com/docs/web-sdk/config/annotations
