Annotations
annotations.Example
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
const viewer = new PDFViewer(container, doc, { annotations: { author: session.user.displayName }, });
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.highlightColors when yellow is not in it.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.'none', 'square', 'circle', 'diamond', 'openArrow', 'closedArrow', 'butt', 'rOpenArrow', 'rClosedArrow', 'slash' — see 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 for what a rebuild keeps).