Skip to main content
Version: Version 5 beta

Interface: PdfToolsViewer

API for interacting with the PDF Viewer SDK, exposing core functionalities for document interaction, event handling, and UI management.

Extends

Properties

dispose()

dispose: () => void

Disposes of the PDF Viewer instance, freeing up resources.

Returns

void

Example

viewer.dispose();

document

document: Document

Groups all the document-related API actions.


documentView

documentView: DocumentView

Groups all the documentView-related API actions.


hideComponents()

hideComponents: (paths) => void

Hides specified UI components in the Viewer.

Parameters

paths

List of components path to hide.

string[] | string[][]

Returns

void

Example

viewer.hideComponents([['pdftools-toolbar', 'pdftools-hamburger-menu']]);

initialize()

initialize: (config, container) => Promise<void>

Initializes the PDF Viewer within a specified container element.

Parameters

config

ViewerConfig

The configuration options for initializing the viewer.

container

HTMLElement

The HTML element to contain the viewer.

Returns

Promise<void>

A promise that resolves when the viewer is initialized.

Example

await viewer.initialize(config, document.getElementById('viewer-container'));

overrideButtonBehavior()

overrideButtonBehavior: (path, eventName, callback) => void

Overrides the behavior of a specific button.

Parameters

path

The selector path to the button component.

string | string[]

eventName

"click"

The name of the event to listen for.

callback

() => void

The callback function to execute when the event is triggered.

Returns

void

Example

viewer.overrideButtonBehavior(['pdftools-toolbar', '#pdftools-save-document-btn']);

plugins

plugins: Plugins

Groups all the plugins-related API actions. Plugins let users extend the viewer with their own interactive layers and behaviors.


showComponents()

showComponents: (paths) => void

Shows specified UI components in the Viewer.

Parameters

paths

List of components path to show.

string[] | string[][]

Returns

void

Example

viewer.showComponents([['pdftools-toolbar', 'pdftools-hamburger-menu']]);

Methods

addEventListener()

addEventListener<K>(eventName, callback): void

Adds an event listener for a specified event.

Type Parameters

K

K extends keyof EventMap

Parameters

eventName

K

The name of the event to listen for.

callback

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

Parameters

eventName

K

The name of the event to stop listening for.

callback

EventMap[K]

The callback function to remove.

Returns

void

Inherited from

EventHandler.removeEventListener