Skip to main content
Version: Version 5 beta

Interface: Document

Groups all the API actions related to document handling.

Extends

Properties

deleteAnnotation()

deleteAnnotation: (annotation) => Promise<void>

Deletes the specified annotation from the document.

Parameters

annotation

Annotation

The annotation to be deleted.

Returns

Promise<void>

Example

await viewer.document.deleteAnnotation(annotation);

download()

download: (fileName, options?) => Promise<void>

Downloads the current document.

Parameters

fileName

string

The name of the file to be downloaded (default is ‘download.pdf’).

options?

DocumentSaveOptions

Document save options

Returns

Promise<void>

A promise that resolves when the document is downloaded.

Example

await viewer.document.download();

getAnnotations()

getAnnotations: () => Promise<Annotation[]>

Retrieves all annotations present in the current document.

Returns

Promise<Annotation[]>

A promise that resolves to an array of annotations.

Example

const annotations = await viewer.document.getAnnotations();

open()

open: (inputDocument) => Promise<void>

Opens a document in the PDF viewer.

Parameters

inputDocument

The input document to be opened, either as a File object or a URI string.

InputFile | InputUri

Returns

Promise<void>

A promise that resolves when the document is opened.

Example

await viewer.document.open({ uri: 'https://example.com/sample.pdf' });

print()

print: (options?) => Promise<void>

Prints the current document.

Parameters

options?

DocumentPrintOptions

Document print options.

Returns

Promise<void>

A promise that resolves when the print dialog is closed.

Example

await viewer.document.print({ pageNumbers: [1, 2], dpi: 300 });

save()

save: (options?) => Promise<Blob>

Saves the current document.

Parameters

options?

DocumentSaveOptions

Document save options

Returns

Promise<Blob>

A promise that resolves to a Blob representing the saved document.

Example

await viewer.document.save();

updateAnnotation()

updateAnnotation: (annotation) => Promise<void>

Updates the specified annotation in the document.

Parameters

annotation

Annotation

The annotation to be updated.

Returns

Promise<void>

A promise that resolves when the annotation is updated.

Example

await viewer.document.updateAnnotation(annotation);

Methods

addEventListener()

addEventListener<K>(eventName, callback): void

Adds an event listener for a specified event.

Type Parameters

K

K extends keyof DocumentEventMap

Parameters

eventName

K

The name of the event to listen for.

callback

DocumentEventMap[K]

The callback function to execute when the event is triggered.

Returns

void

Inherited from

EventHandler.addEventListener


removeEventListener()

removeEventListener<K>(eventName, callback): void

Removes an event listener for a specified event.

Type Parameters

K

K extends keyof DocumentEventMap

Parameters

eventName

K

The name of the event to stop listening for.

callback

DocumentEventMap[K]

The callback function to remove.

Returns

void

Inherited from

EventHandler.removeEventListener