Filtering annotation types

This feature can be using when need to save only specific annotation types and ignore others.

The following are the steps how to filter exported annotations to document: 

  • Instantiate Annotator object with input document path or stream;
  • Instantiate SaveOptions object and set AnnotationType desired annotation type(s), that will presented in resultant document;
  • Call save method with resultant document path or stream and SaveOptions object;

Following code snippet shows how to save only pages with specific annotation type

String outputPath = "FilteringAnnotationTypes.pdf";

Annotator annotator = new Annotator("input.pdf");

AreaAnnotation area = new AreaAnnotation();
area.setBox(new Rectangle(100, 100, 100, 100));

EllipseAnnotation ellipse = new EllipseAnnotation();
ellipse.setBox(new Rectangle(100, 100, 100, 100));

List<AnnotationBase> tmp0 = new ArrayList<AnnotationBase>();

SaveOptions tmp1 = new SaveOptions();
tmp1.setAnnotationTypes(AnnotationType.Ellipse);, tmp1);

More resources

Advanced Usage Topics

To learn more about document annotating features, please refer to the advanced usage section.

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online App

Along with full-featured Java library we provide simple, but powerful free Apps.
You are welcome to annotate your PDF, DOC or DOCX, XLS or XLSX, PPT or PPTX, PNG and other documents with free to use online GroupDocs Annotation App.