Rearrange Tools in Our Viewer Toolbar

PSPDFKit for Web comes with a customizable main toolbar that, by default, includes a number of predefined items. You can rearrange toolbar items using our API.

PSPDFKit is initialized with a default set of items that can be retrieved via PSPDFKit.defaultToolbarItems:

const defaultItems = PSPDFKit.defaultToolbarItems;
console.log(defaultItems);

Items in the toolbar are plain JavaScript objects with the shape of a PSPDFKit.ToolbarItem. To rearrange any item, get the current array of toolbar items via instance.toolbarItems, change the order a toolbar item is displayed in an array, and then set it again to update the UI:

const items = instance.toolbarItems;
// Reverse the order of the toolbar items.
instance.setToolbarItems(items.reverse());