Selecting and Deselecting Annotations
In WebViewer, you can click on an annotation to select it. At this point, you can use the annotationManager
to get the selected annotation, as well as to programmatically select or deselect annotations. This is particularly useful when you need to get the selected annotation or when you need to select/deselect annotation programmatically. The annotationSelected
and annotationDeselected
events will be triggered when an annotation is selected or deselected, respectively.
Get Selected Annotation
You can get the selected annotation with the annotationManager
when the annotationSelected
event is triggered or whenever needed.
const annotationManager = docViewer.getAnnotationManager()
const selectedAnnotation = annotationManager.getSelectedAnnotation()
Select Annotation
You can select an annotation with the selectAnnotation
in the annotationManager
.
const annotationManager = docViewer.getAnnotationManager()
const annotationsList = annotationManager.getAnnotationsList()
annotationManager.selectAnnotation(annotationsList[0])
Deselect Annotation
You can deselect an annotation with the deselectAnnotation
in the annotationManager
.
const annotationManager = docViewer.getAnnotationManager()
const selectedAnnotation = annotationManager.getSelectedAnnotation()
annotationManager.deSelectAnnotation(selectedAnnotation)
Jump to an Annotation
When you need to jump to a specific annotation, you can use the jumpToAnnotation
API to jump to that annotation.
const annotationManager = docViewer.getAnnotationManager()
const annotationsList = annotationManager.getAnnotationsList()
docViewer.jumpToAnnotation(annotationsList[0])