Skip to content

PDFiumAnnotation

@scaryterry/pdfium


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

Represents a single annotation on a PDF page.

get attachmentPointCount(): number

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

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

number


get author(): string | undefined

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

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

string | undefined

set author(value): void

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

ParameterType
valuestring

void


get bounds(): Rect

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

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:145

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:355

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

string | undefined

set contents(value): void

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

ParameterType
valuestring

void


get disposed(): boolean

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

Whether this resource has been disposed.

boolean

Disposable.disposed


get flags(): AnnotationFlags

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

Gets the annotation flags.

AnnotationFlags


get index(): number

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

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:541

Gets the number of ink paths in this ink annotation.

number


get objectCount(): number

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

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:373

The subject of this annotation.

string | undefined

set subject(value): void

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

ParameterType
valuestring

void


get type(): AnnotationType

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

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

AnnotationType

The annotation subtype.

Annotation.type

[dispose](): void

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

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:583

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:675

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:705

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:164

Alias for Symbol.dispose for explicit calls.

void

document.dispose();

Disposable.dispose


focus(): boolean

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

Sets this annotation as the focused annotation in the form.

boolean

True if successful


getAppearance(mode): string | undefined

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

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:621

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:390

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:231

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:775

Gets the font size for a free text annotation.

number | null

The font size, or null if not available


getFormControlCount(): number

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

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

number


getFormControlIndex(): number

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

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:895

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:820

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:856

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:869

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:908

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:844

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:882

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:552

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:474

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:745

Gets the link associated with this link annotation.

PDFLink | null

The link, or null if not found


getRect(): Rect | null

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

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:328

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:509

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:314

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:835

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:731

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:452

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:651

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:415

Sets the border of this annotation.

ParameterTypeDescription
borderAnnotationBorderThe border properties

boolean

True if successful


setColour(colour, colourType): boolean

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

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:299

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:211

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:343

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:758

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:718

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