Customizing an Existing Annotation Tool in Our Viewer Toolbar
It’s possible to customize the following properties of built-in items:
-
title
-
className
-
disabled
-
onPress
In the example below, we add a custom onPress
handler to the first item of the ink annotation toolbar:
PSPDFKit.load({ // ...otherOptions annotationToolbarItems: ( annotation, { defaultAnnotationToolbarItems } ) => { if (annotation instanceof PSPDFKit.Annotations.InkAnnotation) { defaultAnnotationToolbarItems[0].onPress = () => alert("Custom onPress handler!"); return defaultAnnotationToolbarItems; } return defaultAnnotationToolbarItems; } });
Please see the [API Reference][] to learn more about each individual property.
When you set onPress
, it’s added to the parent of the built-in annotation toolbar item.