Compare annotations

On this page

GroupDocs.Annotation v21.7. and later allows you to compare annotations using the Equals method.

The following code snippet shows how to compare annotations:

// This example demonstrates how to update annotation.

// Create an instance of Annotator class
try (Annotator annotator = new Annotator("annotated_file.pdf")) {
    List<AnnotationBase> annotations = annotator.get();
    
    // Create an instance of the ImageAnnotation class and add options
    ImageAnnotation imageAnnotation = new ImageAnnotation();
    imageAnnotation.setBox(new Rectangle(100, 100, 100, 100));
    imageAnnotation.setOpacity(0.7);
    imageAnnotation.setPageNumber(0);
    imageAnnotation.setImagePath("www.google.com.ua/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png");
    imageAnnotation.setAngle(100.0);

    for(int i = 0; i < annotations.size(); i++) {
        // Compare annotations
        if (imageAnnotation.equals(annotations.get(i))) {
                // Do some stuff here...
        }
    }
}

On this page