Interface: Toolbar
Groups all the API actions related to the toolbar UI of the Viewer.
toolbar
button
button:
object
Groups all the API actions related to toolbar buttons.
addEventListener()
addEventListener: (
eventName
,callback
) =>void
Adds an event listener to a toolbar button click event.
Parameters
• eventName: "clicked"
The event name to listen for (e.g., 'clicked'
).
• callback
The callback function to execute when the event is triggered.
Returns
void
Example
PdfToolsViewerApi.toolbar.button.addEventListener('clicked', () => { console.log('callback') });
emitClicked()
emitClicked: (
componentName
,payload
?) =>void
Triggered when a toolbar button is clicked.
Parameters
• componentName: string
The name of the component (button) clicked.
• payload?: unknown
Optional payload with additional information the component needs.
Returns
void
Example
PdfToolsViewerApi.toolbar.button.emitClicked('icon-button-print')
hasEventListener()
hasEventListener: (
eventName
) =>boolean
Checks if an event listener is already attached to a toolbar button click event.
Parameters
• eventName: "clicked"
The event name to check (e.g., 'clicked'
).
Returns
boolean
true
if the event listener is attached, otherwise false
.
Example
const hasEvent = PdfToolsViewerApi.toolbar.button.hasEventListener('clicked');
overrideBehavior()
overrideBehavior: (
viewerEl
,buttonName
,customBehavior
) =>void
Overrides the default behavior of a button with a custom callback.
Parameters
• viewerEl: PdfToolsViewer
The Viewer DOM element.
• buttonName: "pdftools-icon-button-save"
The name of the button to override.
• customBehavior
A callback function defining the new behavior of the button.
Returns
void
fitMode
fitMode:
object
Groups all the API actions related to the fit mode of the toolbar.
addEventListener()
addEventListener: (
eventName
,callback
) =>void
Adds an event listener to the fit mode update event.
Parameters
• eventName: "updated"
The event name to listen for (e.g., 'updated'
).
• callback
The callback function to execute when the event is triggered.
Returns
void
Example
PdfToolsViewerApi.toolbar.fitMode.addEventListener('updated', () => { console.log('callback') });
emitUpdated()
emitUpdated: (
fitMode
) =>void
Triggered when the fit mode is updated.
Parameters
• fitMode: FitMode
The updated fit mode value.
Returns
void
Example
PdfToolsViewerApi.toolbar.fitMode.emitUpdated(FitMode.FitWidth);
hamburgerMenu
hamburgerMenu:
object
Groups all the API actions related to the hamburger menu.
addEventListener()
addEventListener: (
eventName
,callback
) =>void
Adds an event listener to the hamburger menu visibility toggle event.
Parameters
• eventName: "toggleVisibility"
The event name to listen for (e.g., 'toggleVisibility'
).
• callback
The callback function to execute when the event is triggered.
Returns
void
Example
PdfToolsViewerApi.toolbar.hamburgerMenu.addEventListener('toggleVisiblity', () => { console.log('callback') });
emitToggleVisibility()
emitToggleVisibility: (
visible
?) =>void
Toggles the visibility of the hamburger menu.
Parameters
• visible?: boolean
Whether the menu should be visible (default is false).
Returns
void
Example
PdfToolsViewerApi.toolbar.hamburgerMenu.emitToggleVisibility(true);
pageMode
pageMode:
object
Groups all the API actions related to the page mode of the toolbar.
addEventListener()
addEventListener: (
eventName
,callback
) =>void
Adds an event listener to the page mode update event.
Parameters
• eventName: "updated"
The event name to listen for (e.g., 'updated'
).
• callback
The callback function to execute when the event is triggered.
Returns
void
Example
PdfToolsViewerApi.toolbar.pageMode.addEventListener('updated', () => { console.log('callback') });
emitUpdated()
emitUpdated: (
pageMode
) =>void
Triggered when the page mode is updated.
Parameters
• pageMode: PageLayoutMode
The updated page mode value.
Returns
void
Example
PdfToolsViewerApi.toolbar.pageMode.emitUpdated(PageLayoutMode.OneColumn);
thumbnails
thumbnails:
object
Groups all the API actions related to the thumbnails sidebar.
addEventListener()
addEventListener: (
eventName
,callback
) =>void
Parameters
• eventName: "toggleVisibility"
• callback
Returns
void
emitToggleVisibility()
emitToggleVisibility: (
visible
?) =>void
Parameters
• visible?: boolean
Returns
void
Example
PdfToolsViewerApi.toolbar.thumbnails.emitToggleVisibility(true);
PdfToolsViewerApi.toolbar.thumbnails.addEventListener('toggleVisibility', () => { console.log('callback') });
zoom
zoom:
object
Groups all the API actions related to the zoom functionality of the toolbar.
addEventListener()
addEventListener: (
eventName
,callback
) =>void
Adds an event listener to the zoom level update event.
Parameters
• eventName: "updated"
The event name to listen for (e.g., 'updated'
).
• callback
The callback function to execute when the event is triggered.
Returns
void
Example
PdfToolsViewerApi.toolbar.zoom.addEventListener('updated', () => { console.log('callback') });
emitUpdated()
emitUpdated: (
zoom
) =>void
Triggered when the zoom level is updated.
Parameters
• zoom: number
The updated zoom value (between 0 and 1).
Returns
void
Example
PdfToolsViewerApi.toolbar.zoom.emitUpdated(0.5);