Skip to main content
Version: Version 5 beta

Interface: Files

Groups all the API actions related to file handling.

Properties

addEventListener()

addEventListener: (eventName, callback) => void

Adds an event listener for the ‘opened’ event when a file is opened.

Parameters

eventName

"opened"

The event name (e.g., 'opened').

callback

(inputDocument) => void

The callback function to execute when the event is triggered.

Returns

void

Example

viewer.file.addEventListener('opened', () => { console.log('callback') });


emitOpened()

emitOpened: (inputDocument) => void

Triggers an event indicating that a file has been opened.

Parameters

inputDocument

The input document that has been opened, either as a File object or a URI string.

InputFile | InputUri

Returns

void

Example

viewer.file.emitOpened('https://example.com/file.pdf');


removeEventListener()

removeEventListener: (eventName, callback) => void

Removes an event listener for the ‘opened’ event when a file is opened.

Parameters

eventName

"opened"

The event name (e.g., 'opened').

callback

(inputDocument) => void

The callback function to remove.

Returns

void

Example

viewer.file.removeEventListener('opened', () => { console.log('callback') });