Skip to main content
Version: Version 5

Class: Document

Represents a Pdf document.

Extends​

Implements​

Accessors​

annotations​

Get Signature​

get annotations(): AnnotationManager

Returns​

AnnotationManager


controller​

Get Signature​

get controller(): Controller

Gets the Pdf.Controller

Returns​

Controller


forms​

Get Signature​

get forms(): []

Returns​

[]


hasChanges​

Get Signature​

get hasChanges(): boolean

indicates if the document has been changed since the document was opened or last saved

Returns​

boolean


initialDestination​

Get Signature​

get initialDestination(): Destination

Gets the initial destination from the PDF document. This destination specifies where the viewer should navigate when the document opens.

Returns​

Destination

The initial destination, or undefined if not specified in the PDF.


pageCount​

Get Signature​

get pageCount(): number

Returns​

number


pages​

Get Signature​

get pages(): PageList

Returns​

PageList

Methods​

addEventListener()​

addEventListener<K>(type, listener): void

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

Type Parameters​

K​

K extends never

A generic type representing the key of the event type.

Parameters​

type​

K

String representing the event type to listen for.

listener​

(…e) => void

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​

K extends never

A generic type representing the key of the event type.

Parameters​

type​

K

String representing the event type to dispatch.

args​

Parameters<DocumentEventMap[K]>

The data associated with the event.

Returns​

void

Inherited from​

EventEmitter.dispatchEvent


dispose()​

dispose(): void

Disposes of the object, releasing any resources it holds.

The dispose method is responsible for performing cleanup operations and releasing any resources acquired by the object. Once an object is disposed, it should not be used, and attempts to do so may result in undefined behavior.

Returns​

void

Implementation of​

Disposable.dispose


getMetadata()​

getMetadata(): Promise<Metadata>

Returns​

Promise<Metadata>


loadOutlines()​

loadOutlines(): Promise<OutlineItem[]>

Loads outlines of a Pdf.Document.

Returns​

Promise<OutlineItem[]>

A Promise that resolves to an Array containing the outlines.


loadTextFragments()​

loadTextFragments(): Promise<TextFragment[]>

Loads text fragments of a Pdf.Document.

Returns​

Promise<TextFragment[]>

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


registerImage()​

registerImage(image): Promise<PdfImage>

Register the image in the PDF document so it can be reused.

Parameters​

image​

Uint8Array

I

Returns​

Promise<PdfImage>


registerPdfContent()​

registerPdfContent(page): Promise<PdfContent>

Register the PDF page in the PDF document so it can be reused.

Parameters​

page​

Page

The PDF page to register.

Returns​

Promise<PdfContent>

A Promise that resolves to the registered PdfContent.


removeAllListeners()​

removeAllListeners<K>(type): void

Remove all listeners for a given event.

Type Parameters​

K​

K extends never

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​

K extends never

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​

(…e) => void

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

Returns​

void

Inherited from​

EventEmitter.removeEventListener


renderPage()​

renderPage(pageNumber, width, height, renderOptions?): Promise<Image>

Renders a page of the PDF document to an image.

Parameters​

pageNumber​

number

The page number to render (1-indexed).

width​

number

The width of the rendered image.

height​

number

The height of the rendered image.

renderOptions?​

PageRenderOptions

Optional rendering options.

Returns​

Promise<Image>

A Promise that resolves to the rendered Image.


save()​

save(options?): Promise<Blob>

Saves the changes made to the Pdf.Document.

Parameters​

options?​

DocumentSaveOptions = defaultDocumentSaveOptions

Options for configuring the document save behavior.

Returns​

Promise<Blob>

A Promise that resolves to a Blob containing the updated PDF document.