How to remove Measure/Distance comments programmatically

Product: PDFTron using angular
Product Version: latest

I am using angular for the front end.
Is it possible to remove all comments on the right notes panel using angular? for example on a button press.
I can do one by one manually by pressing … Options → Delete. but I’d like to do it programmatically.

Ideally I’d like to take the X & Y coordinates on clicking the mouse (PDF distance measurement), and save them in a database. If getPDFCoordinates(pageNumber, x, y) gets the original coordinates. How Can I get the line coordinate from of the second mouse click (Line, 2 clicks to draw a line).
Many thanks

Hi Samilas,

If you want to remove the comments for Measurement annotations, you could check the following link as a reference: PDFTron Systems Inc. | Documentation.

The implementation would be something similar to

const { annotationManager, AnnotationManager } = instance.Core;
annotationManager.addEventListener('annotationChanged', (annotations, action) => {
    if (action === 'add') {
      const measurementAnnotations = annotations.filter((annot) => annot instanceof instance.Core.Annotations.LineAnnotation);
      measurementAnnotations.forEach((measurement) => {
        measurement.Listable = false;
        console.log('listable is false');
      annotationManager.trigger('annotationChanged', [measurementAnnotations, AnnotationManager.AnnotationChangedActions.MODIFY, { imported: false }]);

This should hide the annotation in the notes panel, therefore you wouldn’t see them in the right notes panel.

To get the start point and end point coordinate of the measurement annotation, you can use the “Start” and “End” property. Please refer to PDFTron Systems Inc. | Documentation

const annotation = ... // this is the Line Annotation, or the Measurement Annotation you specified
const startPoint = annotation.Start
const endPoint = annotation.End