Skip to content

PDFiumAnnotation

@scaryterry/pdfium


Defined in: src/document/annotation.ts:95

Represents a single annotation on a PDF page.

get attachmentPointCount(): number

Defined in: src/document/annotation.ts:748

Gets the number of attachment point sets (quad points) for this markup annotation.

number


get author(): string | undefined

Defined in: src/document/annotation.ts:482

The author (‘T’ key) of this annotation.

string | undefined

set author(value): void

Defined in: src/document/annotation.ts:486

ParameterType
valuestring

void


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.

Rect

The bounding rectangle in page coordinates.

Annotation.bounds


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.

Colour | null

The annotation colour, or null if not set.

Annotation.colour


get contents(): string | undefined

Defined in: src/document/annotation.ts:473

The ‘Contents’ dictionary value (e.g. text body of a note).

string | undefined

set contents(value): void

Defined in: src/document/annotation.ts:477

ParameterType
valuestring

void


get disposed(): boolean

Defined in: src/core/disposable.ts:74

Whether this resource has been disposed.

boolean

Disposable.disposed


get flags(): AnnotationFlags

Defined in: src/document/annotation.ts:191

Gets the annotation flags.

AnnotationFlags


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.

number

Zero-based index of the annotation on its page.

Annotation.index


get inkPathCount(): number

Defined in: src/document/annotation.ts:679

Gets the number of ink paths in this ink annotation.

number


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.

number


get subject(): string | undefined

Defined in: src/document/annotation.ts:491

The subject of this annotation.

string | undefined

set subject(value): void

Defined in: src/document/annotation.ts:495

ParameterType
valuestring

void


get type(): AnnotationType

Defined in: src/document/annotation.ts:130

Gets the annotation subtype (e.g. Text, Highlight, Ink, Link).

AnnotationType

The annotation subtype.

Annotation.type

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

void

Disposable.[dispose]


addInkStroke(points): number

Defined in: src/document/annotation.ts:721

Adds an ink stroke to this ink annotation.

ParameterTypeDescription
pointsreadonly Point[]Array of points defining the ink stroke

number

The index of the added stroke, or -1 on failure


appendAttachmentPoints(quadPoints): boolean

Defined in: src/document/annotation.ts:813

Appends attachment points (quad points) to this markup annotation.

ParameterTypeDescription
quadPointsQuadPointsThe quad points to append

boolean

True if successful


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.

ParameterTypeDescription
objectPDFiumPageObjectThe page object to append

boolean

True if successful


dispose(): void

Defined in: src/core/disposable.ts:179

Alias for Symbol.dispose for explicit calls.

void

document.dispose();

Disposable.dispose


focus(): boolean

Defined in: src/document/annotation.ts:1101

Sets this annotation as the focused annotation in the form.

boolean

True if successful


getAppearance(mode): string | undefined

Defined in: src/document/annotation.ts:575

Gets the appearance stream of this annotation.

ParameterTypeDescription
modeAnnotationAppearanceModeThe appearance mode to retrieve

string | undefined

The appearance stream string, or undefined if not available


getAttachmentPoints(quadIndex): QuadPoints | null

Defined in: src/document/annotation.ts:759

Gets attachment points (quad points) for this markup annotation.

ParameterTypeDescription
quadIndexnumberZero-based quad points index

QuadPoints | null

Quad points, or null if not available


getBorder(): AnnotationBorder | null

Defined in: src/document/annotation.ts:508

Gets the border properties of this annotation.

AnnotationBorder | null

Border properties, or null if not available


getColour(colourType): Colour | null

Defined in: src/document/annotation.ts:276

Gets the colour of this annotation.

ParameterTypeDefault valueDescription
colourTypeAnnotationColourType'stroke'Which colour channel: 'stroke' (default) or 'interior'

Colour | null

The colour, or null if not available


getFontSize(): number | null

Defined in: src/document/annotation.ts:913

Gets the font size for a free text annotation.

number | null

The font size, or null if not available


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.

ParameterTypeDescription
eventFormFieldActionEventThe form field action event type

string | undefined

The JavaScript source string, or undefined if no JS for this event


getFormControlCount(): number

Defined in: src/document/annotation.ts:932

Gets the number of form controls for this form field annotation.

number


getFormControlIndex(): number

Defined in: src/document/annotation.ts:943

Gets the form control index for this form field annotation.

number

The form control index, or -1 if not found


getFormFieldAlternateName(): string | undefined

Defined in: src/document/annotation.ts:1033

Gets the alternate (tooltip) name for this form field widget annotation.

string | undefined

The alternate name, or undefined if not available


getFormFieldExportValue(): string | undefined

Defined in: src/document/annotation.ts:958

Gets the export value of this form field annotation.

string | undefined

The export value, or undefined if not available


getFormFieldFlags(): FormFieldFlags

Defined in: src/document/annotation.ts:994

Gets the form field flags for this widget annotation.

FormFieldFlags

The form field flags bitmask, or FormFieldFlags.None if not a widget


getFormFieldName(): string | undefined

Defined in: src/document/annotation.ts:1007

Gets the form field name for this widget annotation.

string | undefined

The field name, or undefined if not available


getFormFieldOptions(): WidgetOption[] | undefined

Defined in: src/document/annotation.ts:1070

Gets the options for a combo box or list box widget annotation.

WidgetOption[] | undefined

Array of options, or undefined if not a combo/list box or no options


getFormFieldType(): FormFieldType

Defined in: src/document/annotation.ts:982

Gets the form field type for this widget annotation.

FormFieldType

The form field type, or FormFieldType.Unknown if not a widget


getFormFieldValue(): string | undefined

Defined in: src/document/annotation.ts:1020

Gets the current value of this form field widget annotation.

string | undefined

The field value, or undefined if not available


getInkPath(pathIndex): Point[] | null

Defined in: src/document/annotation.ts:690

Gets the points in an ink path.

ParameterTypeDescription
pathIndexnumberZero-based path index

Point[] | null

Array of points, or null if not available


getLine(): LinePoints | null

Defined in: src/document/annotation.ts:612

Gets the line endpoints for a line annotation.

LinePoints | null

Line endpoints, or null if not a line annotation


getLink(): PDFLink | null

Defined in: src/document/annotation.ts:883

Gets the link associated with this link annotation.

PDFLink | null

The link, or null if not found


getNumberValue(key): number | undefined

Defined in: src/document/annotation.ts:458

Gets a numeric value from this annotation’s dictionary.

ParameterTypeDescription
keyDictionaryKeyThe dictionary key

number | undefined

The number value, or undefined if not available


getRect(): Rect | null

Defined in: src/document/annotation.ts:205

Gets the bounding rectangle of this annotation.

Rect | null

The bounding rectangle, or null if not available


getStringValue(key): string | undefined

Defined in: src/document/annotation.ts:426

Gets a string value from this annotation’s dictionary.

ParameterTypeDescription
keyDictionaryKeyThe dictionary key

string | undefined

The string value, or undefined if not available


getVertices(): Point[] | null

Defined in: src/document/annotation.ts:647

Gets the vertices of a polygon or polyline annotation.

Point[] | null

Array of points, or null if not a polygon/polyline annotation


hasKey(key): boolean

Defined in: src/document/annotation.ts:412

Checks if this annotation has a specific key in its dictionary.

ParameterTypeDescription
keyDictionaryKeyThe key name to check

boolean

True if the key exists


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

boolean


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.

ParameterTypeDescription
objectIndexnumberThe zero-based index of the object to remove

boolean

True if successful


setAppearance(mode, value): boolean

Defined in: src/document/annotation.ts:590

Sets the appearance stream of this annotation.

ParameterTypeDescription
modeAnnotationAppearanceModeThe appearance mode to set
valuestring | undefinedThe appearance stream value, or undefined to remove

boolean

True if successful


setAttachmentPoints(quadIndex, quadPoints): boolean

Defined in: src/document/annotation.ts:789

Sets attachment points (quad points) for this markup annotation.

ParameterTypeDescription
quadIndexnumberZero-based quad points index
quadPointsQuadPointsThe quad points to set

boolean

True if successful


setBorder(border): boolean

Defined in: src/document/annotation.ts:533

Sets the border of this annotation.

ParameterTypeDescription
borderAnnotationBorderThe border properties

boolean

True if successful


setColour(colour, colourType): boolean

Defined in: src/document/annotation.ts:328

Sets the colour of this annotation.

ParameterTypeDefault valueDescription
colourColourundefinedThe colour to set
colourTypeAnnotationColourType'stroke'Which colour channel: 'stroke' (default) or 'interior'

boolean

True if successful


setFlags(flags): boolean

Defined in: src/document/annotation.ts:397

Sets the flags of this annotation.

ParameterTypeDescription
flagsAnnotationFlagsThe annotation flags to set

boolean

True if successful


setRect(bounds): boolean

Defined in: src/document/annotation.ts:235

Sets the bounding rectangle of this annotation.

ParameterTypeDescription
boundsRectThe new bounding rectangle

boolean

True if successful


setStringValue(key, value): boolean

Defined in: src/document/annotation.ts:441

Sets a string value in this annotation’s dictionary.

ParameterTypeDescription
keyDictionaryKeyThe dictionary key
valuestringThe string value to set

boolean

True if successful


setURI(uri): boolean

Defined in: src/document/annotation.ts:896

Sets the URI for this link annotation.

ParameterTypeDescription
uristringThe URI to set

boolean

True if successful


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.

ParameterTypeDescription
objectPDFiumPageObjectThe page object to update

boolean

True if successful