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
,fn
) =>void
Add an event listener to a toolbar button being clicked.
Parameters
• eventName: "clicked"
• fn
The callback to execute.
Returns
void
Example
PdfToolsViewerApi.toolbar.button.addEventListener('clicked', () => { console.log('callback') });
clicked()
clicked: (
componentName
,payload
?) =>void
Event triggered when a button in the toolbar gets clicked.
Parameters
• componentName: string
Component name.
• payload?: unknown
Optional payload with information the component needs.
Returns
void
Example
PdfToolsViewerApi.toolbar.button.clicked('icon-button-print')
hasEventListener()
hasEventListener: (
eventName
) =>boolean
Return true if the event already has an event listener for the toolbar.
Parameters
• eventName: "clicked"
Returns
boolean
boolean
Example
const hasEvent = PdfToolsViewerApi.toolbar.button.hasEventListener('clicked');
overrideButtonBehaviour()
overrideButtonBehaviour: (
viewerEl
,buttonName
,customBehaviour
) =>void
Overrides the default behaviour of a button with a custom function.
Parameters
• viewerEl: PdfToolsViewer
The Viewer DOM element.
• buttonName: "pdftools-icon-button-save"
The identifier of the button whose behaviour is to be overridden.
• customBehaviour
A callback function defining the new behaviour for the button. This function is executed in place of the default button action.
Returns
void
fitMode
fitMode:
object
addEventListener()
addEventListener: (
eventName
,fn
) =>void
Add an event listener to a toolbar fitMode being updated.
Parameters
• eventName: "updated"
• fn
The callback to execute.
Returns
void
Example
PdfToolsViewerApi.toolbar.fitMode.addEventListener('updated', () => { console.log('callback') });
updated()
updated: (
fitMode
) =>void
Event triggered when the toolbar fitMode is updated.
Parameters
• fitMode: FitMode
The fitMode it updated to.
Returns
void
Example
PdfToolsViewerApi.toolbar.fitMode.updated(1);
hamburgerMenu
hamburgerMenu:
object
addEventListener()
addEventListener: (
eventName
,fn
) =>void
Add an event listener to the hamburguer menu being toggled.
Parameters
• eventName: "toggleVisibility"
• fn
The callback to execute.
Returns
void
Example
PdfToolsViewerApi.toolbar.hamburguerMenu.addEventListener('toggleVisiblity', () => { console.log('callback') });
toggleVisibility()
toggleVisibility: (
visible
?) =>void
Toggle the visibility of the options in the hamburguer menu.
Parameters
• visible?: boolean
True if we wanted it to be visible; false otherwise.
Returns
void
Example
PdfToolsViewerApi.toolbar.hamburguerMenu.toggleVisibility(true);
pageMode
pageMode:
object
addEventListener()
addEventListener: (
eventName
,fn
) =>void
Add an event listener to a toolbar pageMode being updated.
Parameters
• eventName: "updated"
• fn
The callback to execute.
Returns
void
Example
PdfToolsViewerApi.toolbar.pageMode.addEventListener('updated', () => { console.log('callback') });
updated()
updated: (
pageMode
) =>void
Event triggered when the toolbar pageMode is updated.
Parameters
• pageMode: PageLayoutMode
The pageMode it updated to.
Returns
void
Example
PdfToolsViewerApi.toolbar.pageMode.updated(1);
zoom
zoom:
object
addEventListener()
addEventListener: (
eventName
,fn
) =>void
Add an event listener to a toolbar zoom being updated.
Parameters
• eventName: "updated"
• fn
The callback to execute.
Returns
void
Example
PdfToolsViewerApi.toolbar.zoom.addEventListener('updated', () => { console.log('callback') });
updated()
updated: (
zoom
) =>void
Event triggered when the toolbar zoom is updated.
Parameters
• zoom: number
The zoom it updated to. Between 0 and 1.
Returns
void
Example
PdfToolsViewerApi.toolbar.zoom.updated(0.5);