Removing a Tool from the Toolbar in Our JavaScript Viewer

PSPDFKit for Web comes with a customizable main toolbar that, by default, includes a number of predefined items. You can remove any toolbar item you want 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 remove any item, first get the array of current toolbar items via instance.toolbaritems, then filter it and set the new array:

const items = instance.toolbarItems;
// Hide the toolbar item with the `id` "ink"
// by removing it from the array of items.
instance.setToolbarItems(items.filter((item) => item.type !== "ink"));