Expand all, Collapse all annotations

Hello, is there a way to add Expand All, Collapse all annotations feature?

Just want to clarify what do you mean by “expand/Collapse all annotations”, Do you mean by open all the comments under the comments sections?

If not, please clarify your question by providing a screenshot.


Hi Oscar,
Yes, You are correct. Expand all comments and Collapse all comments.


Unfortunately, we don’t have an API to achieve this. When expanding one comment area, there are a few logics bind with it, for example, 1)Deselect other annotation, 2) Center the page to the selected annotation, 3) Set annotation read status, plus others…

If you don’t care about to keep those logics, you can try the following code:

const annotationManager = docViewer.getAnnotationManager();
// open notes panel:

// get all annotation
const annotations = annotationManager.getAnnotationsList();

// optional: filter annotations by type
// ...

// expand them all:
// https://www.pdftron.com/api/web/CoreControls.AnnotationManager.html#selectAnnotations__anchor