Hiding certain annotations in WebViewer notes panel

Sometimes it is useful to display only a subset of annotations in the notes panel. This guide talks about how the notes panel can be configured to hide certain annotations by using the annotation's Listable property or the setCustomNoteFilter API.

Listable

Listable is a property that exists on all types of annotations. It controls if an annotation should be shown in the notes panel. The following example shows how you can hide all rectangle annotations.

1WebViewer({
2 // your constructor options here
3}, viewerElement)
4 .then(instance => {
5 const { annotationManager } = instance.Core;
6
7 annotationManager.addEventListener('annotationChanged', (annotations, action) => {
8 if (action === 'add') {
9 const rectangles = annotations.filter(annot => annot instanceof instance.Core.Annotations.RectangleAnnotation);
10
11 rectangles.forEach(rectangle => {
12 rectangle.Listable = false;
13 });
14
15 annotationManager.drawAnnotationsFromList(rectangles);
16 annotationManager.trigger('annotationChanged', [rectangles, 'modify']);
17 }
18 })
19 });

setCustomNoteFilter

An annotation will neither appear in thumbnails nor show in the printed document if it's not Listable. Sometimes we may just want to customize the notes panel and leave other components untouched. In this case, setCustomNoteFilter is the right choice.

1WebViewer({
2 // your constructor options here
3}, viewerElement)
4 .then(instance => {
5 // only show non-rectangle annotations
6 instance.UI.setCustomNoteFilter(annot => !(annot instanceof instance.Core.Annotations.RectangleAnnotation))
7 });

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales