Skip to main content
Version: Version 5 beta

Class: Page

A single page in a Pdf document.

Extends

Accessors

document

get document(): Document

the pdf document to which the page belongs

Returns

Document


hasChanges

get hasChanges(): boolean

indicates if the page or its content has been changed since the document was last saved

Returns

boolean


height

get height(): number

Height of the page in PDF coordinates. This represents the height of the page, taking into account the rotation.

Returns

number


isDeleted

get isDeleted(): boolean

indicates whether the page was deleted

Returns

boolean


originalHeight

get originalHeight(): number

Original height of the page in PDF coordinates. This represents the original height of the page without considering any rotation.

Returns

number


originalWidth

get originalWidth(): number

Original width of the page in PDF coordinates. This represents the original width of the page without considering any rotation.

Returns

number


pageNumber

get pageNumber(): number

page number

Returns

number


rotation

get rotation(): Rotation

Rotation of the page

Returns

Rotation


width

get width(): number

Width of the page in PDF coordinates. This represents the width of the page, taking into account the rotation.

Returns

number

Methods

addEventListener()

addEventListener<K>(type, listener): void

Register a function that will be called whenever the specified event is delivered.

Type Parameters

K extends "textFragmentsLoaded"

A generic type representing the key of the event type.

Parameters

type: K

String representing the event type to listen for.

listener

The function that will be executed when an event of the specified type occurs.

Returns

void

Inherited from

EventEmitter.addEventListener


dispatchEvent()

dispatchEvent<K>(type, args): void

Dispatches an event to all registered listeners.

Type Parameters

K extends "textFragmentsLoaded"

A generic type representing the key of the event type.

Parameters

type: K

String representing the event type to dispatch.

args: Parameters<PageEventMap[K]>

The data associated with the event.

Returns

void

Inherited from

EventEmitter.dispatchEvent


getTextFragments()

getTextFragments(): TextFragment[]

Gets text fragments of a Pdf.Page.

Returns

TextFragment[]

A Promise that resolves to an Array containing the text fragments.

Throws

Pdf.NotLoadedError if text fragments are not loaded yet.


loadTextFragments()

loadTextFragments(): Promise<TextFragment[]>

Loads text fragments of a Pdf.Page.

Returns

Promise<TextFragment[]>

A Promise that resolves to an Array containing the text fragments.


removeAllListeners()

removeAllListeners<K>(type): void

Remove all listeners for a given event.

Type Parameters

K extends "textFragmentsLoaded"

A generic type representing the key of the event type.

Parameters

type: K

String representing the event for which to remove all listeners.

Returns

void

Inherited from

EventEmitter.removeAllListeners


removeEventListener()

removeEventListener<K>(type, listener): void

Removes an event listener previously registered with addEventListener.

Type Parameters

K extends "textFragmentsLoaded"

A generic type representing the key of the event type.

Parameters

type: K

String representing the event for which to remove an event listener.

listener

The event listener function of the event handler to remove from the event target.

Returns

void

Inherited from

EventEmitter.removeEventListener


render()

render(renderOptions): Promise<Blob>

Render the given page

Parameters

renderOptions: PageRenderOptions

Returns

Promise<Blob>

Blob containing the image data


rotate()

rotate(direction, degree): void

Rotates the page in the specified direction by the specified degree

The rotation can only be done in steps of 90 degrees or a multiple thereof

Parameters

direction: RotationDirection

clockwise or counter-clockwise

degree: number = 90

rotation in degrees in multiples of 90

Returns

void


transformDocumentViewPointQuadrilateralToPdfPointQuadrilateral()

transformDocumentViewPointQuadrilateralToPdfPointQuadrilateral(quadrilateral, width, height, rotation): Quadrilateral<PdfPoint>

Converts a quadrilateral from document view coordinates to PDF coordinates.

This function transforms a Quadrilateral<DocumentViewPoint>, which corresponds to a quadrilateral scaled proportionally based on the rendered size of the page on screen, to a Quadrilateral<PdfPoint>, which is measured in PDF units. The conversion takes into account the dimensions of the document view page canvas and the rotation of the page.

Parameters

quadrilateral: Quadrilateral<DocumentViewPoint>

The Quadrilateral<DocumentViewPoint> object representing the quadrilateral in document view coordinates.

width: number

The width of the document view page canvas.

height: number

The height of the document view page canvas.

rotation: Rotation

The rotation of the page.

Returns

Quadrilateral<PdfPoint>

A new instance of Quadrilateral<PdfPoint> representing the converted coordinates in PDF units.


transformDocumentViewPointRectangleToPdfPointRectangle()

transformDocumentViewPointRectangleToPdfPointRectangle(rectangle, width, height, rotation): Rectangle<PdfPoint>

Converts a rectangle from document view coordinates to PDF coordinates.

This function transforms a Rectangle<DocumentViewPoint>, which corresponds to a rectangle scaled proportionally based on the rendered size of the page on screen, to a Rectangle<PdfPoint>, which is measured in PDF units. The conversion takes into account the dimensions of the document view page canvas and the rotation of the page.

Parameters

rectangle: Rectangle<DocumentViewPoint>

The Rectangle<DocumentViewPoint> object representing the rectangle in document view coordinates.

width: number

The width of the document view page canvas.

height: number

The height of the document view page canvas.

rotation: Rotation

The rotation of the page.

Returns

Rectangle<PdfPoint>

A new instance of Rectangle<PdfPoint> representing the converted coordinates in PDF units.


transformDocumentViewPointToPdfPoint()

transformDocumentViewPointToPdfPoint(point, width, height, rotation): PdfPoint

Converts a point from document view coordinates to PDF coordinates.

This function transforms a DocumentViewPoint, which corresponds to a PDF point scaled proportionally based on the rendered size of the page on screen, to a PdfPoint, which is measured in PDF units. The conversion takes into account the dimensions of the document view page canvas and the rotation of the page.

Parameters

point: DocumentViewPoint

The DocumentViewPoint object representing the point in document view coordinates.

width: number

The width of the document view page canvas.

height: number

The height of the document view page canvas.

rotation: Rotation

The rotation of the page.

Returns

PdfPoint

A new instance of PdfPoint representing the converted coordinates in PDF units.


transformPdfPointQuadrilateralToDocumentViewPointQuadrilateral()

transformPdfPointQuadrilateralToDocumentViewPointQuadrilateral(quadrilateral, width, height, rotation): Quadrilateral<DocumentViewPoint>

Converts a quadrilateral from PDF coordinates to document view coordinates.

This function transforms a Quadrilateral<PdfPoint>, which is measured in PDF units, to a Quadrilateral<DocumentViewPoint>, which corresponds to a quadrilateral scaled proportionally based on the rendered size of the page on screen. The conversion takes into account the dimensions of the document view page canvas and the rotation of the page.

Parameters

quadrilateral: Quadrilateral<PdfPoint>

The Quadrilateral<PdfPoint> object representing the quadrilateral in PDF coordinates.

width: number

The width of the document view page canvas.

height: number

The height of the document view page canvas.

rotation: Rotation

The rotation of the page.

Returns

Quadrilateral<DocumentViewPoint>

A new instance of Quadrilateral<DocumentViewPoint> representing the converted coordinates in document view units.


transformPdfPointRectangleToDocumentViewPointRectangle()

transformPdfPointRectangleToDocumentViewPointRectangle(rectangle, width, height, rotation): Rectangle<DocumentViewPoint>

Converts a rectangle from PDF coordinates to document view coordinates.

This function transforms a Rectangle<PdfPoint>, which is measured in PDF units, to a Rectangle<DocumentViewPoint>, which corresponds to a rectangle scaled proportionally based on the rendered size of the page on screen. The conversion takes into account the dimensions of the document view page canvas and the rotation of the page.

Parameters

rectangle: Rectangle<PdfPoint>

The Rectangle<PdfPoint> object representing the rectangle in PDF coordinates.

width: number

The width of the document view page canvas.

height: number

The height of the document view page canvas.

rotation: Rotation

The rotation of the page.

Returns

Rectangle<DocumentViewPoint>

A new instance of Rectangle<DocumentViewPoint> representing the converted coordinates in document view units.


transformPdfPointToDocumentViewPoint()

transformPdfPointToDocumentViewPoint(point, width, height, rotation): DocumentViewPoint

Converts a point from PDF coordinates to document view coordinates.

This function transforms a PdfPoint, which is measured in PDF units, to a DocumentViewPoint, which corresponds to a PDF point scaled proportionally based on the rendered size of the page on screen. The conversion takes into account the dimensions of the document view page canvas and the rotation of the page.

Parameters

point: PdfPoint

The PdfPoint object representing the point in PDF coordinates.

width: number

The width of the document view page canvas.

height: number

The height of the document view page canvas.

rotation: Rotation

The rotation of the page.

Returns

DocumentViewPoint

A new instance of DocumentViewPoint representing the converted coordinates in document view units.


calculateRotatedDocumentViewPoint()

static calculateRotatedDocumentViewPoint(point, rotation, pageWidth, pageHeight): DocumentViewPoint

Calculates rotated document view point around page center.

Parameters

point: DocumentViewPoint

The DocumentViewPoint object representing point to be rotated around page center.

rotation: Rotation

The rotation value to apply to a point.

pageWidth: number

pageHeight: number

Returns

DocumentViewPoint

A new instance of DocumentViewPoint representing the rotated point around page center.


calculateRotatedPdfPoint()

static calculateRotatedPdfPoint(point, rotation, pageWidth, pageHeight): PdfPoint

Calculates rotated PDF point around center page center.

Parameters

point: PdfPoint

The PdfPoint object representing point to be rotated around page center.

rotation: Rotation

The rotation value to apply to a point.

pageWidth: number

pageHeight: number

Returns

PdfPoint

A new instance of PdfPoint representing the rotated point around page center.