Skip to main content
Version: Version 5

Class: Document

Represents a Pdf document.

Extends

Implements

Accessors

annotations

get annotations(): AnnotationManager

Returns

AnnotationManager


controller

get controller(): Controller

Gets the Pdf.Controller

Returns

Controller


forms

get forms(): []

Returns

[]


hasChanges

get hasChanges(): boolean

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

Returns

boolean


pageCount

get pageCount(): number

Returns

number


pages

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 extends never

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


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

Returns

Promise<PdfContent>


removeAllListeners()

removeAllListeners<K>(type): void

Remove all listeners for a given event.

Type Parameters

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

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): Promise<Image>

Parameters

pageNumber: number

width: number

height: number

Returns

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