PDFiumAnnotation
Defined in: src/document/annotation.ts:95
Represents a single annotation on a PDF page.
Extends
Section titled “Extends”Implements
Section titled “Implements”Accessors
Section titled “Accessors”attachmentPointCount
Section titled “attachmentPointCount”Get Signature
Section titled “Get Signature”get attachmentPointCount():
number
Defined in: src/document/annotation.ts:748
Gets the number of attachment point sets (quad points) for this markup annotation.
Returns
Section titled “Returns”number
author
Section titled “author”Get Signature
Section titled “Get Signature”get author():
string|undefined
Defined in: src/document/annotation.ts:482
The author (‘T’ key) of this annotation.
Returns
Section titled “Returns”string | undefined
Set Signature
Section titled “Set Signature”set author(
value):void
Defined in: src/document/annotation.ts:486
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
value | string |
Returns
Section titled “Returns”void
bounds
Section titled “bounds”Get Signature
Section titled “Get Signature”get bounds():
Rect
Defined in: src/document/annotation.ts:144
Gets the bounding rectangle of this annotation.
Returns a zero-rect if the annotation has no rectangle set. Use getRect to distinguish between “no rect” (null) and a valid rect.
This getter satisfies the Annotation interface.
Returns
Section titled “Returns”The bounding rectangle in page coordinates.
Implementation of
Section titled “Implementation of”colour
Section titled “colour”Get Signature
Section titled “Get Signature”get colour():
Colour|null
Defined in: src/document/annotation.ts:155
Gets the stroke colour of this annotation, if set.
This value is cached at construction time and invalidated by setColour.
This getter satisfies the Annotation interface.
Returns
Section titled “Returns”Colour | null
The annotation colour, or null if not set.
Implementation of
Section titled “Implementation of”contents
Section titled “contents”Get Signature
Section titled “Get Signature”get contents():
string|undefined
Defined in: src/document/annotation.ts:473
The ‘Contents’ dictionary value (e.g. text body of a note).
Returns
Section titled “Returns”string | undefined
Set Signature
Section titled “Set Signature”set contents(
value):void
Defined in: src/document/annotation.ts:477
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
value | string |
Returns
Section titled “Returns”void
disposed
Section titled “disposed”Get Signature
Section titled “Get Signature”get disposed():
boolean
Defined in: src/core/disposable.ts:74
Whether this resource has been disposed.
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”Get Signature
Section titled “Get Signature”get flags():
AnnotationFlags
Defined in: src/document/annotation.ts:191
Gets the annotation flags.
Returns
Section titled “Returns”Get Signature
Section titled “Get Signature”get index():
number
Defined in: src/document/annotation.ts:164
Gets the zero-based index of this annotation on its page.
This value is cached at construction time.
Returns
Section titled “Returns”number
Zero-based index of the annotation on its page.
Implementation of
Section titled “Implementation of”inkPathCount
Section titled “inkPathCount”Get Signature
Section titled “Get Signature”get inkPathCount():
number
Defined in: src/document/annotation.ts:679
Gets the number of ink paths in this ink annotation.
Returns
Section titled “Returns”number
objectCount
Section titled “objectCount”Get Signature
Section titled “Get Signature”get objectCount():
number
Defined in: src/document/annotation.ts:183
Gets the number of page objects in this annotation.
Only ink and stamp annotations typically have objects.
Returns
Section titled “Returns”number
subject
Section titled “subject”Get Signature
Section titled “Get Signature”get subject():
string|undefined
Defined in: src/document/annotation.ts:491
The subject of this annotation.
Returns
Section titled “Returns”string | undefined
Set Signature
Section titled “Set Signature”set subject(
value):void
Defined in: src/document/annotation.ts:495
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
value | string |
Returns
Section titled “Returns”void
Get Signature
Section titled “Get Signature”get type():
AnnotationType
Defined in: src/document/annotation.ts:130
Gets the annotation subtype (e.g. Text, Highlight, Ink, Link).
Returns
Section titled “Returns”The annotation subtype.
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”[dispose]()
Section titled “[dispose]()”[dispose]():
void
Defined in: src/core/disposable.ts:163
Dispose of this resource, freeing WASM memory.
This method is idempotent - calling it multiple times has no effect after the first call.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”addInkStroke()
Section titled “addInkStroke()”addInkStroke(
points):number
Defined in: src/document/annotation.ts:721
Adds an ink stroke to this ink annotation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
points | readonly Point[] | Array of points defining the ink stroke |
Returns
Section titled “Returns”number
The index of the added stroke, or -1 on failure
appendAttachmentPoints()
Section titled “appendAttachmentPoints()”appendAttachmentPoints(
quadPoints):boolean
Defined in: src/document/annotation.ts:813
Appends attachment points (quad points) to this markup annotation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
quadPoints | QuadPoints | The quad points to append |
Returns
Section titled “Returns”boolean
True if successful
appendObject()
Section titled “appendObject()”appendObject(
object):boolean
Defined in: src/document/annotation.ts:843
Appends a page object to this annotation.
Only ink and stamp annotations support object manipulation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
object | PDFiumPageObject | The page object to append |
Returns
Section titled “Returns”boolean
True if successful
dispose()
Section titled “dispose()”dispose():
void
Defined in: src/core/disposable.ts:179
Alias for Symbol.dispose for explicit calls.
Returns
Section titled “Returns”void
Example
Section titled “Example”document.dispose();Inherited from
Section titled “Inherited from”focus()
Section titled “focus()”focus():
boolean
Defined in: src/document/annotation.ts:1101
Sets this annotation as the focused annotation in the form.
Returns
Section titled “Returns”boolean
True if successful
getAppearance()
Section titled “getAppearance()”getAppearance(
mode):string|undefined
Defined in: src/document/annotation.ts:575
Gets the appearance stream of this annotation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
mode | AnnotationAppearanceMode | The appearance mode to retrieve |
Returns
Section titled “Returns”string | undefined
The appearance stream string, or undefined if not available
getAttachmentPoints()
Section titled “getAttachmentPoints()”getAttachmentPoints(
quadIndex):QuadPoints|null
Defined in: src/document/annotation.ts:759
Gets attachment points (quad points) for this markup annotation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
quadIndex | number | Zero-based quad points index |
Returns
Section titled “Returns”QuadPoints | null
Quad points, or null if not available
getBorder()
Section titled “getBorder()”getBorder():
AnnotationBorder|null
Defined in: src/document/annotation.ts:508
Gets the border properties of this annotation.
Returns
Section titled “Returns”AnnotationBorder | null
Border properties, or null if not available
getColour()
Section titled “getColour()”getColour(
colourType):Colour|null
Defined in: src/document/annotation.ts:276
Gets the colour of this annotation.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
colourType | AnnotationColourType | 'stroke' | Which colour channel: 'stroke' (default) or 'interior' |
Returns
Section titled “Returns”Colour | null
The colour, or null if not available
getFontSize()
Section titled “getFontSize()”getFontSize():
number|null
Defined in: src/document/annotation.ts:913
Gets the font size for a free text annotation.
Returns
Section titled “Returns”number | null
The font size, or null if not available
getFormAdditionalActionJavaScript()
Section titled “getFormAdditionalActionJavaScript()”getFormAdditionalActionJavaScript(
event):string|undefined
Defined in: src/document/annotation.ts:1051
Gets JavaScript associated with a form field additional action event.
Form fields can have JavaScript actions triggered by events like keystroke, format, validate, or calculate. This method retrieves the JavaScript for a specific event type.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
event | FormFieldActionEvent | The form field action event type |
Returns
Section titled “Returns”string | undefined
The JavaScript source string, or undefined if no JS for this event
getFormControlCount()
Section titled “getFormControlCount()”getFormControlCount():
number
Defined in: src/document/annotation.ts:932
Gets the number of form controls for this form field annotation.
Returns
Section titled “Returns”number
getFormControlIndex()
Section titled “getFormControlIndex()”getFormControlIndex():
number
Defined in: src/document/annotation.ts:943
Gets the form control index for this form field annotation.
Returns
Section titled “Returns”number
The form control index, or -1 if not found
getFormFieldAlternateName()
Section titled “getFormFieldAlternateName()”getFormFieldAlternateName():
string|undefined
Defined in: src/document/annotation.ts:1033
Gets the alternate (tooltip) name for this form field widget annotation.
Returns
Section titled “Returns”string | undefined
The alternate name, or undefined if not available
getFormFieldExportValue()
Section titled “getFormFieldExportValue()”getFormFieldExportValue():
string|undefined
Defined in: src/document/annotation.ts:958
Gets the export value of this form field annotation.
Returns
Section titled “Returns”string | undefined
The export value, or undefined if not available
getFormFieldFlags()
Section titled “getFormFieldFlags()”getFormFieldFlags():
FormFieldFlags
Defined in: src/document/annotation.ts:994
Gets the form field flags for this widget annotation.
Returns
Section titled “Returns”The form field flags bitmask, or FormFieldFlags.None if not a widget
getFormFieldName()
Section titled “getFormFieldName()”getFormFieldName():
string|undefined
Defined in: src/document/annotation.ts:1007
Gets the form field name for this widget annotation.
Returns
Section titled “Returns”string | undefined
The field name, or undefined if not available
getFormFieldOptions()
Section titled “getFormFieldOptions()”getFormFieldOptions():
WidgetOption[] |undefined
Defined in: src/document/annotation.ts:1070
Gets the options for a combo box or list box widget annotation.
Returns
Section titled “Returns”WidgetOption[] | undefined
Array of options, or undefined if not a combo/list box or no options
getFormFieldType()
Section titled “getFormFieldType()”getFormFieldType():
FormFieldType
Defined in: src/document/annotation.ts:982
Gets the form field type for this widget annotation.
Returns
Section titled “Returns”The form field type, or FormFieldType.Unknown if not a widget
getFormFieldValue()
Section titled “getFormFieldValue()”getFormFieldValue():
string|undefined
Defined in: src/document/annotation.ts:1020
Gets the current value of this form field widget annotation.
Returns
Section titled “Returns”string | undefined
The field value, or undefined if not available
getInkPath()
Section titled “getInkPath()”getInkPath(
pathIndex):Point[] |null
Defined in: src/document/annotation.ts:690
Gets the points in an ink path.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
pathIndex | number | Zero-based path index |
Returns
Section titled “Returns”Point[] | null
Array of points, or null if not available
getLine()
Section titled “getLine()”getLine():
LinePoints|null
Defined in: src/document/annotation.ts:612
Gets the line endpoints for a line annotation.
Returns
Section titled “Returns”LinePoints | null
Line endpoints, or null if not a line annotation
getLink()
Section titled “getLink()”getLink():
PDFLink|null
Defined in: src/document/annotation.ts:883
Gets the link associated with this link annotation.
Returns
Section titled “Returns”PDFLink | null
The link, or null if not found
getNumberValue()
Section titled “getNumberValue()”getNumberValue(
key):number|undefined
Defined in: src/document/annotation.ts:458
Gets a numeric value from this annotation’s dictionary.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
key | DictionaryKey | The dictionary key |
Returns
Section titled “Returns”number | undefined
The number value, or undefined if not available
getRect()
Section titled “getRect()”getRect():
Rect|null
Defined in: src/document/annotation.ts:205
Gets the bounding rectangle of this annotation.
Returns
Section titled “Returns”Rect | null
The bounding rectangle, or null if not available
getStringValue()
Section titled “getStringValue()”getStringValue(
key):string|undefined
Defined in: src/document/annotation.ts:426
Gets a string value from this annotation’s dictionary.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
key | DictionaryKey | The dictionary key |
Returns
Section titled “Returns”string | undefined
The string value, or undefined if not available
getVertices()
Section titled “getVertices()”getVertices():
Point[] |null
Defined in: src/document/annotation.ts:647
Gets the vertices of a polygon or polyline annotation.
Returns
Section titled “Returns”Point[] | null
Array of points, or null if not a polygon/polyline annotation
hasKey()
Section titled “hasKey()”hasKey(
key):boolean
Defined in: src/document/annotation.ts:412
Checks if this annotation has a specific key in its dictionary.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
key | DictionaryKey | The key name to check |
Returns
Section titled “Returns”boolean
True if the key exists
isWidget()
Section titled “isWidget()”isWidget():
boolean
Defined in: src/document/annotation.ts:973
Returns true if this annotation is a valid form widget (Widget subtype with a known field type).
Returns
Section titled “Returns”boolean
removeObject()
Section titled “removeObject()”removeObject(
objectIndex):boolean
Defined in: src/document/annotation.ts:869
Removes a page object from this annotation.
Only ink and stamp annotations support object manipulation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
objectIndex | number | The zero-based index of the object to remove |
Returns
Section titled “Returns”boolean
True if successful
setAppearance()
Section titled “setAppearance()”setAppearance(
mode,value):boolean
Defined in: src/document/annotation.ts:590
Sets the appearance stream of this annotation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
mode | AnnotationAppearanceMode | The appearance mode to set |
value | string | undefined | The appearance stream value, or undefined to remove |
Returns
Section titled “Returns”boolean
True if successful
setAttachmentPoints()
Section titled “setAttachmentPoints()”setAttachmentPoints(
quadIndex,quadPoints):boolean
Defined in: src/document/annotation.ts:789
Sets attachment points (quad points) for this markup annotation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
quadIndex | number | Zero-based quad points index |
quadPoints | QuadPoints | The quad points to set |
Returns
Section titled “Returns”boolean
True if successful
setBorder()
Section titled “setBorder()”setBorder(
border):boolean
Defined in: src/document/annotation.ts:533
Sets the border of this annotation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
border | AnnotationBorder | The border properties |
Returns
Section titled “Returns”boolean
True if successful
setColour()
Section titled “setColour()”setColour(
colour,colourType):boolean
Defined in: src/document/annotation.ts:328
Sets the colour of this annotation.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
colour | Colour | undefined | The colour to set |
colourType | AnnotationColourType | 'stroke' | Which colour channel: 'stroke' (default) or 'interior' |
Returns
Section titled “Returns”boolean
True if successful
setFlags()
Section titled “setFlags()”setFlags(
flags):boolean
Defined in: src/document/annotation.ts:397
Sets the flags of this annotation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
flags | AnnotationFlags | The annotation flags to set |
Returns
Section titled “Returns”boolean
True if successful
setRect()
Section titled “setRect()”setRect(
bounds):boolean
Defined in: src/document/annotation.ts:235
Sets the bounding rectangle of this annotation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
bounds | Rect | The new bounding rectangle |
Returns
Section titled “Returns”boolean
True if successful
setStringValue()
Section titled “setStringValue()”setStringValue(
key,value):boolean
Defined in: src/document/annotation.ts:441
Sets a string value in this annotation’s dictionary.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
key | DictionaryKey | The dictionary key |
value | string | The string value to set |
Returns
Section titled “Returns”boolean
True if successful
setURI()
Section titled “setURI()”setURI(
uri):boolean
Defined in: src/document/annotation.ts:896
Sets the URI for this link annotation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
uri | string | The URI to set |
Returns
Section titled “Returns”boolean
True if successful
updateObject()
Section titled “updateObject()”updateObject(
object):boolean
Defined in: src/document/annotation.ts:856
Updates a page object in this annotation.
The object must already be in the annotation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
object | PDFiumPageObject | The page object to update |
Returns
Section titled “Returns”boolean
True if successful