PDFiumPage
Defined in: src/document/page.ts:153
Represents a single page in a PDF document.
Pages are loaded lazily and must be disposed when no longer needed.
Use the using keyword for automatic disposal.
Example
Section titled “Example”using page = document.getPage(0);const size = page.size;console.log(`Page size: ${size.width}x${size.height}`);Extends
Section titled “Extends”Implements
Section titled “Implements”Accessors
Section titled “Accessors”annotationCount
Section titled “annotationCount”Get Signature
Section titled “Get Signature”get annotationCount():
number
Defined in: src/document/page.ts:1058
Get the number of annotations on this page.
Returns
Section titled “Returns”number
artBox
Section titled “artBox”Get Signature
Section titled “Get Signature”get artBox():
PageBox|undefined
Defined in: src/document/page.ts:426
Get the art box (content boundaries).
This is a convenience method equivalent to getPageBox(PageBoxType.ArtBox).
Returns
Section titled “Returns”PageBox | undefined
The art box or undefined if not explicitly set
bleedBox
Section titled “bleedBox”Get Signature
Section titled “Get Signature”get bleedBox():
PageBox|undefined
Defined in: src/document/page.ts:404
Get the bleed box (printing bleed area).
This is a convenience method equivalent to getPageBox(PageBoxType.BleedBox).
Returns
Section titled “Returns”PageBox | undefined
The bleed box or undefined if not explicitly set
boundingBox
Section titled “boundingBox”Get Signature
Section titled “Get Signature”get boundingBox():
PageBox
Defined in: src/document/page.ts:438
Get the effective bounding box of the page.
This returns the bounding box that encompasses all page content, considering all page transformations.
Returns
Section titled “Returns”The page bounding box
charCount
Section titled “charCount”Get Signature
Section titled “Get Signature”get charCount():
number
Defined in: src/document/page.ts:2041
Get the total number of characters on this page.
This includes all text characters that can be extracted.
Returns
Section titled “Returns”number
cropBox
Section titled “cropBox”Get Signature
Section titled “Get Signature”get cropBox():
PageBox|undefined
Defined in: src/document/page.ts:393
Get the crop box (visible region).
This is a convenience method equivalent to getPageBox(PageBoxType.CropBox).
Returns
Section titled “Returns”PageBox | undefined
The crop box or undefined if not explicitly set
disposed
Section titled “disposed”Get Signature
Section titled “Get Signature”get disposed():
boolean
Defined in: src/core/disposable.ts:73
Whether this resource has been disposed.
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”height
Section titled “height”Get Signature
Section titled “Get Signature”get height():
number
Defined in: src/document/page.ts:267
Get the height of the page in points.
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”Get Signature
Section titled “Get Signature”get index():
number
Defined in: src/document/page.ts:244
The zero-based index of this page.
Returns
Section titled “Returns”number
The zero-based index of this page.
Implementation of
Section titled “Implementation of”mediaBox
Section titled “mediaBox”Get Signature
Section titled “Get Signature”get mediaBox():
PageBox|undefined
Defined in: src/document/page.ts:382
Get the media box (physical page boundaries).
This is a convenience method equivalent to getPageBox(PageBoxType.MediaBox).
Returns
Section titled “Returns”PageBox | undefined
The media box or undefined if not set
objectCount
Section titled “objectCount”Get Signature
Section titled “Get Signature”get objectCount():
number
Defined in: src/document/page.ts:1010
Get the number of objects on this page.
Returns
Section titled “Returns”number
rotation
Section titled “rotation”Get Signature
Section titled “Get Signature”get rotation():
PageRotation
Defined in: src/document/page.ts:275
Get the page rotation as stored in the PDF.
Returns
Section titled “Returns”Set Signature
Section titled “Set Signature”set rotation(
rotation):void
Defined in: src/document/page.ts:286
Set the page rotation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
rotation | PageRotation | The rotation value to set |
Returns
Section titled “Returns”void
Page rotation.
Implementation of
Section titled “Implementation of”Get Signature
Section titled “Get Signature”get size():
PageSize
Defined in: src/document/page.ts:251
Get the page dimensions in points (1/72 inch).
Returns
Section titled “Returns”Page dimensions.
Implementation of
Section titled “Implementation of”trimBox
Section titled “trimBox”Get Signature
Section titled “Get Signature”get trimBox():
PageBox|undefined
Defined in: src/document/page.ts:415
Get the trim box (final trimmed dimensions).
This is a convenience method equivalent to getPageBox(PageBoxType.TrimBox).
Returns
Section titled “Returns”PageBox | undefined
The trim box or undefined if not explicitly set
webLinkCount
Section titled “webLinkCount”Get Signature
Section titled “Get Signature”get webLinkCount():
number
Defined in: src/document/page.ts:2694
Count the number of web links detected in the page text.
Web links are URLs automatically detected in the page text content, not interactive link annotations.
Returns
Section titled “Returns”number
Get Signature
Section titled “Get Signature”get width():
number
Defined in: src/document/page.ts:259
Get the width of the page in points.
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”[dispose]()
Section titled “[dispose]()”[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.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Inherited from
Section titled “Inherited from”annotations()
Section titled “annotations()”annotations():
IterableIterator<PDFiumAnnotation>
Defined in: src/document/page.ts:1149
Iterate annotations on this page lazily.
Each yielded annotation holds an open native handle — use using or
call dispose() when done. Annotations are opened one at a time,
making this more memory-efficient than getAnnotations() for large
annotation sets.
Returns
Section titled “Returns”IterableIterator<PDFiumAnnotation>
canFormRedo()
Section titled “canFormRedo()”canFormRedo():
boolean
Defined in: src/document/page.ts:1255
Check if redo is available for form field editing on this page.
Returns
Section titled “Returns”boolean
canFormUndo()
Section titled “canFormUndo()”canFormUndo():
boolean
Defined in: src/document/page.ts:1244
Check if undo is available for form field editing on this page.
Returns
Section titled “Returns”boolean
createAnnotation()
Section titled “createAnnotation()”createAnnotation(
type):PDFiumAnnotation|null
Defined in: src/document/page.ts:1708
Create a new annotation on this page.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
type | AnnotationType | The annotation type to create |
Returns
Section titled “Returns”PDFiumAnnotation | null
The new annotation, or null if creation failed
createImageObject()
Section titled “createImageObject()”createImageObject():
PDFiumImageObject|null
Defined in: src/document/page.ts:1647
Create a new image page object.
The returned object must be inserted into a page or annotation,
or destroyed via obj.destroy().
Returns
Section titled “Returns”PDFiumImageObject | null
A new image page object, or null if failed
deviceToPage()
Section titled “deviceToPage()”deviceToPage(
context,deviceX,deviceY):PageCoordinate
Defined in: src/document/page.ts:2983
Convert device coordinates (pixels) to page coordinates (points).
This is useful for translating mouse click positions into page space for operations like text selection or hit testing.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
context | CoordinateTransformContext | The coordinate transform context defining the viewport |
deviceX | number | X coordinate in device space (pixels) |
deviceY | number | Y coordinate in device space (pixels) |
Returns
Section titled “Returns”The corresponding point in page coordinate space
Example
Section titled “Example”const context = { startX: 0, startY: 0, sizeX: 800, sizeY: 600, rotate: PageRotation.None,};const pageCoord = page.deviceToPage(context, mouseX, mouseY);Throws
Section titled “Throws”If the device coordinates are not finite numbers
dispose()
Section titled “dispose()”dispose():
void
Defined in: src/core/disposable.ts:164
Alias for Symbol.dispose for explicit calls.
Returns
Section titled “Returns”void
Example
Section titled “Example”document.dispose();Inherited from
Section titled “Inherited from”executePageAction()
Section titled “executePageAction()”executePageAction(
actionType):void
Defined in: src/document/page.ts:3085
Executes a page action for forms.
Triggers JavaScript actions associated with page events (open/close). This is used to run any scripts that are attached to page lifecycle events in interactive PDF forms.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
actionType | PageActionType | The type of page action to execute |
Returns
Section titled “Returns”void
Example
Section titled “Example”// Trigger page open actionpage.executePageAction(PageActionType.Open);
// Before closing, trigger close actionpage.executePageAction(PageActionType.Close);findText()
Section titled “findText()”findText(
query,flags):IterableIterator<TextSearchResult>
Defined in: src/document/page.ts:1827
Search for text on this page.
Returns a generator yielding search results with position information. The search handle is cleaned up when the generator finishes or is closed.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
query | string | undefined | The text to search for |
flags | TextSearchFlags | TextSearchFlags.None | Search flags (case sensitivity, whole word, etc.) |
Returns
Section titled “Returns”IterableIterator<TextSearchResult>
Throws
Section titled “Throws”If the text page fails to load
Implementation of
Section titled “Implementation of”flatten()
Section titled “flatten()”flatten(
flags):FlattenResult
Defined in: src/document/page.ts:1547
Flatten annotations and form fields into page content.
After flattening, annotations and form fields become part of the page content and can no longer be edited separately.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
flags | FlattenFlags | FlattenFlags.NormalDisplay | Flatten flags (0 for normal display, 1 for print) |
Returns
Section titled “Returns”The flatten result
formChar()
Section titled “formChar()”formChar(
charCode,modifier):boolean
Defined in: src/document/page.ts:1440
Notify form fill environment of a character input event.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
charCode | number | Character code |
modifier | FormModifierFlags | Keyboard modifier flags |
Returns
Section titled “Returns”boolean
True if the event was handled
formDoubleClick()
Section titled “formDoubleClick()”formDoubleClick(
modifier,x,y):boolean
Defined in: src/document/page.ts:1395
Notify form fill environment of a double-click event.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
modifier | FormModifierFlags | Keyboard modifier flags |
x | number | X coordinate in page space |
y | number | Y coordinate in page space |
Returns
Section titled “Returns”boolean
True if the event was handled
formFocus()
Section titled “formFocus()”formFocus(
modifier,x,y):boolean
Defined in: src/document/page.ts:1343
Notify form fill environment of focus at a point.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
modifier | FormModifierFlags | Keyboard modifier flags |
x | number | X coordinate in page space |
y | number | Y coordinate in page space |
Returns
Section titled “Returns”boolean
True if the event was handled
formKeyDown()
Section titled “formKeyDown()”formKeyDown(
keyCode,modifier):boolean
Defined in: src/document/page.ts:1410
Notify form fill environment of a key down event.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
keyCode | number | Virtual key code |
modifier | FormModifierFlags | Keyboard modifier flags |
Returns
Section titled “Returns”boolean
True if the event was handled
formKeyUp()
Section titled “formKeyUp()”formKeyUp(
keyCode,modifier):boolean
Defined in: src/document/page.ts:1425
Notify form fill environment of a key up event.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
keyCode | number | Virtual key code |
modifier | FormModifierFlags | Keyboard modifier flags |
Returns
Section titled “Returns”boolean
True if the event was handled
formMouseDown()
Section titled “formMouseDown()”formMouseDown(
button,modifier,x,y):boolean
Defined in: src/document/page.ts:1360
Notify form fill environment of a mouse button down event.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
button | FormMouseButton | Which mouse button (‘left’ or ‘right’) |
modifier | FormModifierFlags | Keyboard modifier flags |
x | number | X coordinate in page space |
y | number | Y coordinate in page space |
Returns
Section titled “Returns”boolean
True if the event was handled
formMouseMove()
Section titled “formMouseMove()”formMouseMove(
modifier,x,y):boolean
Defined in: src/document/page.ts:1301
Notify form fill environment of mouse movement.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
modifier | FormModifierFlags | Keyboard modifier flags (shift, ctrl, alt) |
x | number | X coordinate in page space |
y | number | Y coordinate in page space |
Returns
Section titled “Returns”boolean
True if the event was handled
formMouseUp()
Section titled “formMouseUp()”formMouseUp(
button,modifier,x,y):boolean
Defined in: src/document/page.ts:1378
Notify form fill environment of a mouse button up event.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
button | FormMouseButton | Which mouse button (‘left’ or ‘right’) |
modifier | FormModifierFlags | Keyboard modifier flags |
x | number | X coordinate in page space |
y | number | Y coordinate in page space |
Returns
Section titled “Returns”boolean
True if the event was handled
formMouseWheel()
Section titled “formMouseWheel()”formMouseWheel(
modifier,x,y,deltaX,deltaY):boolean
Defined in: src/document/page.ts:1319
Notify form fill environment of mouse wheel scroll.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
modifier | FormModifierFlags | Keyboard modifier flags |
x | number | X coordinate in page space |
y | number | Y coordinate in page space |
deltaX | number | Horizontal scroll delta |
deltaY | number | Vertical scroll delta |
Returns
Section titled “Returns”boolean
True if the event was handled
formRedo()
Section titled “formRedo()”formRedo():
boolean
Defined in: src/document/page.ts:1281
Redo the last undone form field editing operation on this page.
Returns
Section titled “Returns”boolean
True if redo was successful
formSelectAllText()
Section titled “formSelectAllText()”formSelectAllText():
boolean
Defined in: src/document/page.ts:1497
Select all text in the currently focused form field.
Returns
Section titled “Returns”boolean
True if successful
formUndo()
Section titled “formUndo()”formUndo():
boolean
Defined in: src/document/page.ts:1268
Undo the last form field editing operation on this page.
Returns
Section titled “Returns”boolean
True if undo was successful
generateContent()
Section titled “generateContent()”generateContent():
boolean
Defined in: src/document/page.ts:1586
Generate the page content stream.
Call this after modifying page objects to persist changes.
Returns
Section titled “Returns”boolean
True if successful
getAnnotation()
Section titled “getAnnotation()”getAnnotation(
index):PDFiumAnnotation
Defined in: src/document/page.ts:1073
Get an annotation by index.
The returned annotation holds an open native handle and a borrow on this page’s resources. Dispose the annotation when done.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
index | number | Zero-based annotation index |
Returns
Section titled “Returns”The annotation wrapper
Throws
Section titled “Throws”If the index is out of range or the annotation cannot be loaded
getAnnotations()
Section titled “getAnnotations()”getAnnotations():
PDFiumAnnotation[]
Defined in: src/document/page.ts:1125
Get all annotations on this page.
Important: Each annotation holds an open native handle that retains the page’s native resources. You must dispose every annotation when done, otherwise native memory will not be freed.
For memory-efficient iteration, prefer the annotations() generator which
yields one annotation at a time with using support.
Returns
Section titled “Returns”Example
Section titled “Example”// Array pattern — caller must dispose each annotationconst annots = page.getAnnotations();try { for (const annot of annots) { console.log(annot.type); }} finally { for (const annot of annots) { annot.dispose(); }}
// Generator pattern (preferred) — automatic disposalfor (using annot of page.annotations()) { console.log(annot.type);}Implementation of
Section titled “Implementation of”getCharacterInfo()
Section titled “getCharacterInfo()”getCharacterInfo(
charIndex):CharacterInfo|undefined
Defined in: src/document/page.ts:2280
Get extended information about a character at the specified index.
This combines multiple character properties into a single object for convenience when you need comprehensive character information.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
charIndex | number | Zero-based character index |
Returns
Section titled “Returns”CharacterInfo | undefined
Character info or undefined if invalid index
getCharAngle()
Section titled “getCharAngle()”getCharAngle(
charIndex):number
Defined in: src/document/page.ts:2143
Get the rotation angle of a character at the specified index.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
charIndex | number | Zero-based character index |
Returns
Section titled “Returns”number
Rotation angle in radians
getCharBox()
Section titled “getCharBox()”getCharBox(
charIndex):CharBox|undefined
Defined in: src/document/page.ts:1849
Get the bounding box of a character by its index.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
charIndex | number | Zero-based character index |
Returns
Section titled “Returns”CharBox | undefined
The character bounding box, or undefined if the index is invalid
Throws
Section titled “Throws”If the text page fails to load
getCharFillColour()
Section titled “getCharFillColour()”getCharFillColour(
charIndex):Colour|undefined
Defined in: src/document/page.ts:2241
Get the fill colour of a character at the specified index.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
charIndex | number | Zero-based character index |
Returns
Section titled “Returns”Colour | undefined
Fill colour or undefined if unavailable
getCharFontName()
Section titled “getCharFontName()”getCharFontName(
charIndex):string|undefined
Defined in: src/document/page.ts:2107
Get the font name of a character at the specified index.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
charIndex | number | Zero-based character index |
Returns
Section titled “Returns”string | undefined
Font name, or undefined if unavailable
getCharFontSize()
Section titled “getCharFontSize()”getCharFontSize(
charIndex):number
Defined in: src/document/page.ts:2071
Get the font size of a character at the specified index.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
charIndex | number | Zero-based character index |
Returns
Section titled “Returns”number
Font size in points, or 0 if invalid
getCharFontWeight()
Section titled “getCharFontWeight()”getCharFontWeight(
charIndex):number
Defined in: src/document/page.ts:2089
Get the font weight of a character at the specified index.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
charIndex | number | Zero-based character index |
Returns
Section titled “Returns”number
Font weight (100-900), or -1 if invalid/unavailable
getCharIndexAtPos()
Section titled “getCharIndexAtPos()”getCharIndexAtPos(
x,y,xTolerance,yTolerance):number
Defined in: src/document/page.ts:1895
Get the character index at a given position in page coordinates.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
x | number | undefined | X position in page coordinates |
y | number | undefined | Y position in page coordinates |
xTolerance | number | DEFAULT_CHAR_POSITION_TOLERANCE | Horizontal tolerance in points (default: 10) |
yTolerance | number | DEFAULT_CHAR_POSITION_TOLERANCE | Vertical tolerance in points (default: 10) |
Returns
Section titled “Returns”number
The zero-based character index, or -1 if no character is at the position, or -3 if the position is outside the page
getCharLooseBox()
Section titled “getCharLooseBox()”getCharLooseBox(
charIndex):CharBox|undefined
Defined in: src/document/page.ts:1867
Get the loose bounding box of a character by its index.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
charIndex | number | Zero-based character index |
Returns
Section titled “Returns”CharBox | undefined
The character loose bounding box, or undefined if the index is invalid
getCharOrigin()
Section titled “getCharOrigin()”getCharOrigin(
charIndex): {x:number;y:number; } |undefined
Defined in: src/document/page.ts:2163
Get the origin point of a character at the specified index.
The origin is typically at the baseline of the character.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
charIndex | number | Zero-based character index |
Returns
Section titled “Returns”{ x: number; y: number; } | undefined
Origin point {x, y} or undefined if invalid
getCharRenderMode()
Section titled “getCharRenderMode()”getCharRenderMode(
charIndex):TextRenderMode
Defined in: src/document/page.ts:2125
Get the text render mode of a character at the specified index.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
charIndex | number | Zero-based character index |
Returns
Section titled “Returns”Text render mode
getCharStrokeColour()
Section titled “getCharStrokeColour()”getCharStrokeColour(
charIndex):Colour|undefined
Defined in: src/document/page.ts:2259
Get the stroke colour of a character at the specified index.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
charIndex | number | Zero-based character index |
Returns
Section titled “Returns”Colour | undefined
Stroke colour or undefined if unavailable
getCharUnicode()
Section titled “getCharUnicode()”getCharUnicode(
charIndex):number
Defined in: src/document/page.ts:2053
Get the Unicode code point of a character at the specified index.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
charIndex | number | Zero-based character index |
Returns
Section titled “Returns”number
Unicode code point, or 0 if invalid
getDecodedThumbnailData()
Section titled “getDecodedThumbnailData()”getDecodedThumbnailData():
Uint8Array<ArrayBufferLike> |undefined
Defined in: src/document/page.ts:560
Get the decoded thumbnail image data.
This returns the raw pixel data of the embedded thumbnail image, decoded from whatever format it was stored in (typically JPEG).
Returns
Section titled “Returns”Uint8Array<ArrayBufferLike> | undefined
The decoded thumbnail pixel data, or undefined if not available
getFocusableSubtypes()
Section titled “getFocusableSubtypes()”getFocusableSubtypes():
AnnotationType[]
Defined in: src/document/page.ts:1759
Get the focusable annotation subtypes.
Returns
Section titled “Returns”Array of focusable annotation types
getFocusableSubtypesCount()
Section titled “getFocusableSubtypesCount()”getFocusableSubtypesCount():
number
Defined in: src/document/page.ts:1744
Get the count of focusable annotation subtypes.
Returns
Section titled “Returns”number
The number of focusable subtypes
getFormFieldTypeAtPoint()
Section titled “getFormFieldTypeAtPoint()”getFormFieldTypeAtPoint(
x,y):FormFieldType|null
Defined in: src/document/page.ts:1170
Get the form field type at the specified point.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
x | number | X coordinate in page coordinates |
y | number | Y coordinate in page coordinates |
Returns
Section titled “Returns”FormFieldType | null
The form field type at the point, or null if none
getFormFieldZOrderAtPoint()
Section titled “getFormFieldZOrderAtPoint()”getFormFieldZOrderAtPoint(
x,y):number
Defined in: src/document/page.ts:1189
Get the Z-order of a form field at the specified point.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
x | number | X coordinate in page coordinates |
y | number | Y coordinate in page coordinates |
Returns
Section titled “Returns”number
The Z-order of the form field at the point, or -1 if none
getFormFocusedText()
Section titled “getFormFocusedText()”getFormFocusedText():
string|undefined
Defined in: src/document/page.ts:1453
Get the text in the currently focused form field.
Returns
Section titled “Returns”string | undefined
The focused text, or undefined if no focused field
getFormSelectedText()
Section titled “getFormSelectedText()”getFormSelectedText():
string|undefined
Defined in: src/document/page.ts:1202
Get the currently selected text in a form field on this page.
Returns
Section titled “Returns”string | undefined
The selected text, or undefined if no selection
getLinkAtPoint()
Section titled “getLinkAtPoint()”getLinkAtPoint(
x,y):PDFLink|null
Defined in: src/document/page.ts:2613
Get the link at a specific point on the page.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
x | number | X coordinate in page units |
y | number | Y coordinate in page units |
Returns
Section titled “Returns”PDFLink | null
The link at the point, or null if none
getLinks()
Section titled “getLinks()”getLinks():
PDFLink[]
Defined in: src/document/page.ts:2684
Enumerate all links on the page.
For pages with many links, prefer using the links() generator.
Returns
Section titled “Returns”PDFLink[]
Array of links found on the page
getLinkZOrderAtPoint()
Section titled “getLinkZOrderAtPoint()”getLinkZOrderAtPoint(
x,y):number
Defined in: src/document/page.ts:2633
Get the z-order of the link at a specific point.
Returns the z-order index (0-based, where 0 is bottom) of the link at the specified point, or -1 if no link is found.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
x | number | X coordinate in page units |
y | number | Y coordinate in page units |
Returns
Section titled “Returns”number
getObjects()
Section titled “getObjects()”getObjects():
PDFiumPageObject[]
Defined in: src/document/page.ts:1051
Get all page objects (text, images, paths, etc.).
For large pages, prefer using the objects() generator.
Returns
Section titled “Returns”An array of page objects with type and bounding box information
Implementation of
Section titled “Implementation of”getPageBox()
Section titled “getPageBox()”getPageBox(
boxType):PageBox|undefined
Defined in: src/document/page.ts:304
Get a specific page box.
PDF pages can have multiple box definitions:
- MediaBox: Physical page boundaries (required)
- CropBox: Visible region (defaults to MediaBox)
- BleedBox: Bleed area for printing (defaults to CropBox)
- TrimBox: Final trimmed page dimensions (defaults to CropBox)
- ArtBox: Meaningful content boundaries (defaults to CropBox)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
boxType | PageBoxType | The type of box to retrieve |
Returns
Section titled “Returns”PageBox | undefined
The page box or undefined if not explicitly set
Implementation of
Section titled “Implementation of”getRawThumbnailData()
Section titled “getRawThumbnailData()”getRawThumbnailData():
Uint8Array<ArrayBufferLike> |undefined
Defined in: src/document/page.ts:575
Get the raw thumbnail image data.
This returns the thumbnail data in its original encoded format (e.g., JPEG, PNG). The format can be determined from the data header.
Returns
Section titled “Returns”Uint8Array<ArrayBufferLike> | undefined
The raw thumbnail data, or undefined if not available
getStructureTree()
Section titled “getStructureTree()”getStructureTree():
StructureElement[] |undefined
Defined in: src/document/page.ts:2344
Get the structure tree for this page (tagged PDF accessibility info).
Returns an array of root structure elements, or undefined if the page has no structure tree (i.e. the PDF is not tagged).
For large structure trees, prefer the lazy structureElements generator.
Returns
Section titled “Returns”StructureElement[] | undefined
getText()
Section titled “getText()”getText():
string
Defined in: src/document/page.ts:987
Extract text content from the page.
Returns the full text of the page as a single string. The text preserves the logical reading order determined by PDFium, including whitespace and line breaks embedded in the PDF content stream. No trimming is applied.
Returns
Section titled “Returns”string
The extracted text
Throws
Section titled “Throws”If text extraction fails
getTextInRect for extracting text within a bounding rectangle
Implementation of
Section titled “Implementation of”getTextInRect()
Section titled “getTextInRect()”getTextInRect(
left,top,right,bottom):string
Defined in: src/document/page.ts:1918
Get the text within a rectangular region of the page.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
left | number | Left edge of the rectangle in page coordinates |
top | number | Top edge of the rectangle in page coordinates |
right | number | Right edge of the rectangle in page coordinates |
bottom | number | Bottom edge of the rectangle in page coordinates |
Returns
Section titled “Returns”string
The text within the rectangle (no trimming is applied)
getText for extracting all text on the page
getTextLayout()
Section titled “getTextLayout()”getTextLayout():
object
Defined in: src/document/page.ts:1968
Get efficient text layout data (characters and bounding boxes).
Optimised for bulk extraction. Returns a single string of text and a flat Float32Array
of bounding boxes — 4 values per character in the order [left, right, bottom, top],
so rects.length === text.length * 4. Access character i bounds via
rects[i*4] (left), rects[i*4+1] (right), rects[i*4+2] (bottom), rects[i*4+3] (top).
Returns
Section titled “Returns”object
Object containing { text, rects }
| Name | Type | Defined in |
|---|---|---|
rects | Float32Array | src/document/page.ts:1968 |
text | string | src/document/page.ts:1968 |
getThumbnailAsBitmap()
Section titled “getThumbnailAsBitmap()”getThumbnailAsBitmap():
RenderResult|undefined
Defined in: src/document/page.ts:504
Get the embedded thumbnail image as a rendered result.
Returns the thumbnail as RGBA pixel data in a RenderResult, matching the format returned by render.
Returns
Section titled “Returns”RenderResult | undefined
The thumbnail as a render result, or undefined if not available
getWebLinks()
Section titled “getWebLinks()”getWebLinks():
WebLink[]
Defined in: src/document/page.ts:2715
Get automatically detected web links from the page text.
These are URLs found in the text content, not interactive link annotations.
Returns
Section titled “Returns”WebLink[]
Array of detected web links with their URLs and positions
hasCharUnicodeMapError()
Section titled “hasCharUnicodeMapError()”hasCharUnicodeMapError(
charIndex):boolean
Defined in: src/document/page.ts:2223
Check if a character at the specified index has a Unicode mapping error.
This indicates the character could not be properly mapped to Unicode during text extraction.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
charIndex | number | Zero-based character index |
Returns
Section titled “Returns”boolean
hasThumbnail()
Section titled “hasThumbnail()”hasThumbnail():
boolean
Defined in: src/document/page.ts:488
Check if the page has an embedded thumbnail image.
Returns
Section titled “Returns”boolean
True if a thumbnail exists, false otherwise
hasTransparency()
Section titled “hasTransparency()”hasTransparency():
boolean
Defined in: src/document/page.ts:1561
Check if this page contains transparency.
Returns
Section titled “Returns”boolean
True if the page contains transparency
isAnnotationObjectSubtypeSupported()
Section titled “isAnnotationObjectSubtypeSupported()”isAnnotationObjectSubtypeSupported(
subtype):boolean
Defined in: src/document/page.ts:1734
Check if an annotation subtype supports adding/updating/removing objects.
Currently supported subtypes are ink and stamp.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
subtype | AnnotationType | The annotation subtype to check |
Returns
Section titled “Returns”boolean
True if the subtype supports object operations
isAnnotationSubtypeSupported()
Section titled “isAnnotationSubtypeSupported()”isAnnotationSubtypeSupported(
subtype):boolean
Defined in: src/document/page.ts:1721
Check if an annotation subtype is supported for object extraction.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
subtype | AnnotationType | The annotation subtype to check |
Returns
Section titled “Returns”boolean
True if the subtype supports object operations
isCharGenerated()
Section titled “isCharGenerated()”isCharGenerated(
charIndex):boolean
Defined in: src/document/page.ts:2183
Check if a character at the specified index was generated.
Generated characters are not from the original PDF content stream, but were synthesised during text extraction.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
charIndex | number | Zero-based character index |
Returns
Section titled “Returns”boolean
isCharHyphen()
Section titled “isCharHyphen()”isCharHyphen(
charIndex):boolean
Defined in: src/document/page.ts:2203
Check if a character at the specified index is a hyphen.
This can be used to detect soft hyphens that may indicate word breaks across lines.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
charIndex | number | Zero-based character index |
Returns
Section titled “Returns”boolean
isFormIndexSelected()
Section titled “isFormIndexSelected()”isFormIndexSelected(
index):boolean
Defined in: src/document/page.ts:1526
Check if an index is selected in a listbox or combobox.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
index | number | The option index to check |
Returns
Section titled “Returns”boolean
True if the index is selected
links()
Section titled “links()”links():
IterableIterator<PDFLink>
Defined in: src/document/page.ts:2650
Iterate over links lazily.
Use this for memory-efficient iteration over many links.
Returns
Section titled “Returns”IterableIterator<PDFLink>
Example
Section titled “Example”for (const link of page.links()) { console.log(link.actionType);}objects()
Section titled “objects()”objects():
IterableIterator<PDFiumPageObject>
Defined in: src/document/page.ts:1027
Iterate over page objects lazily.
Use this for memory-efficient iteration over many page objects.
Returns
Section titled “Returns”IterableIterator<PDFiumPageObject>
Example
Section titled “Example”for (const obj of page.objects()) { console.log(obj.type);}Implementation of
Section titled “Implementation of”pageToDevice()
Section titled “pageToDevice()”pageToDevice(
context,pageX,pageY):DeviceCoordinate
Defined in: src/document/page.ts:3036
Convert page coordinates (points) to device coordinates (pixels).
This is useful for positioning UI elements over specific page content or for drawing annotations at precise locations.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
context | CoordinateTransformContext | The coordinate transform context defining the viewport |
pageX | number | X coordinate in page space (points) |
pageY | number | Y coordinate in page space (points) |
Returns
Section titled “Returns”The corresponding point in device coordinate space
Example
Section titled “Example”const context = { startX: 0, startY: 0, sizeX: 800, sizeY: 600, rotate: PageRotation.None,};const deviceCoord = page.pageToDevice(context, textBounds.left, textBounds.top);Throws
Section titled “Throws”If the page coordinates are not finite numbers
removeAnnotation()
Section titled “removeAnnotation()”removeAnnotation(
index):boolean
Defined in: src/document/page.ts:1697
Remove an annotation from this page.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
index | number | Zero-based annotation index |
Returns
Section titled “Returns”boolean
True if successful
removeObject()
Section titled “removeObject()”removeObject(
obj):boolean
Defined in: src/document/page.ts:1574
Remove a page object from this page.
After removal, call generateContent() to update the page content stream.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
obj | PDFiumPageObject | The page object to remove |
Returns
Section titled “Returns”boolean
True if successful
render()
Section titled “render()”render(
options):RenderResult
Defined in: src/document/page.ts:589
Render the page to a bitmap.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options | RenderOptions | Rendering options |
Returns
Section titled “Returns”The rendered bitmap data
Throws
Section titled “Throws”If rendering fails
Implementation of
Section titled “Implementation of”replaceFormSelection()
Section titled “replaceFormSelection()”replaceFormSelection(
text):void
Defined in: src/document/page.ts:1230
Replace the currently selected text in a form field.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
text | string | The text to replace the selection with |
Returns
Section titled “Returns”void
replaceFormSelectionAndKeep()
Section titled “replaceFormSelectionAndKeep()”replaceFormSelectionAndKeep(
text):void
Defined in: src/document/page.ts:1481
Replace the selected text in a form field and keep the selection.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
text | string | The text to replace the selection with |
Returns
Section titled “Returns”void
setClipPath()
Section titled “setClipPath()”setClipPath(
box):boolean
Defined in: src/document/page.ts:1628
Create, insert, and destroy a clip path in a single operation.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
box | PageBox | The clip path rectangle in page coordinates |
Returns
Section titled “Returns”boolean
True if the clip path was created and inserted successfully
setFocusableSubtypes()
Section titled “setFocusableSubtypes()”setFocusableSubtypes(
subtypes):boolean
Defined in: src/document/page.ts:1796
Set the focusable annotation subtypes.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
subtypes | AnnotationType[] | Array of annotation types that should be focusable |
Returns
Section titled “Returns”boolean
True if successful
setFormIndexSelected()
Section titled “setFormIndexSelected()”setFormIndexSelected(
index,selected):boolean
Defined in: src/document/page.ts:1512
Set the selection state of an index in a listbox or combobox.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
index | number | The option index to select/deselect |
selected | boolean | True to select, false to deselect |
Returns
Section titled “Returns”boolean
True if successful
setPageBox()
Section titled “setPageBox()”setPageBox(
boxType,box):void
Defined in: src/document/page.ts:353
Set a specific page box.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
boxType | PageBoxType | The type of box to set |
box | PageBox | The box coordinates in points |
Returns
Section titled “Returns”void
startProgressiveRender()
Section titled “startProgressiveRender()”startProgressiveRender(
options):ProgressiveRenderContext
Defined in: src/document/page.ts:710
Start progressive rendering of the page.
Returns a ProgressiveRenderContext that owns the render resources.
Use continue() to advance the render, and dispose when done.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options | RenderOptions | Render options (same as render()) |
Returns
Section titled “Returns”A disposable render context
Throws
Section titled “Throws”If progressive rendering is unavailable or setup fails
Example
Section titled “Example”using render = page.startProgressiveRender({ scale: 2 });
while (render.status === ProgressiveRenderStatus.ToBeContinued) { render.continue();}
if (render.status === ProgressiveRenderStatus.Done) { const result = render.getResult();}Implementation of
Section titled “Implementation of”IPageReader.startProgressiveRender
structureElements()
Section titled “structureElements()”structureElements():
IterableIterator<StructureElement,any,any> |undefined
Defined in: src/document/page.ts:2391
Iterate over root structure elements lazily.
Each yielded element includes its full subtree of children (eagerly loaded).
Returns undefined if the page has no structure tree.
The structure tree handle is kept open for the lifetime of the generator. Dispose or exhaust the generator to release it.
Returns
Section titled “Returns”IterableIterator<StructureElement, any, any> | undefined
A generator yielding root-level structure elements, or undefined if the page is not tagged
Throws
Section titled “Throws”If the structure tree depth exceeds the maximum
Example
Section titled “Example”const elements = page.structureElements();if (elements) { for (const element of elements) { console.log(element.type); }}transformAnnotations()
Section titled “transformAnnotations()”transformAnnotations(
matrix):void
Defined in: src/document/page.ts:470
Transform all annotations on the page.
Applies an affine transformation matrix to all annotations.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
matrix | TransformMatrix | The transformation matrix to apply |
Returns
Section titled “Returns”void
transformWithClip()
Section titled “transformWithClip()”transformWithClip(
matrix,clipRect?):boolean
Defined in: src/document/page.ts:1598
Transform this page with a matrix and optional clip rectangle.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
matrix | TransformMatrix | The transformation matrix to apply |
clipRect? | PageBox | Optional clip rectangle in page coordinates |
Returns
Section titled “Returns”boolean
True if successful