Filtering annotations by type on saving document

On this page

To save the annotations of specific types only, follow these steps:

  1. Instantiate the Annotator class. Specify the input document path or stream.
  2. Instantiate the SaveOptions class. Call the setAnnotationType() method and specify the annotation type(s) to save.
  3. Call the save() method with the output document path or stream. Specify the SaveOptions class as a parameter.

The following code snippet shows how to save only pages with specific annotation type:

// This example demonstrates saving result document with specified annotations.

// Create an instance of Annotator class Annotator annotator = new Annotator(Constants.ANNOTATED_BIG); try { // Create an instance of AreaAnnotation class and set options AreaAnnotation area = new AreaAnnotation(); area.setBox(new Rectangle(100, 100, 100, 100)); area.setBackgroundColor(65535); area.setPageNumber(1);

// Create an instance of EllipseAnnotation class and set options
EllipseAnnotation ellipse = new EllipseAnnotation();
ellipse.setBox(new Rectangle(100, 100, 100, 100));

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

SaveOptions tmp1 = new SaveOptions();

// Add annotation and save to file, tmp1);

} finally { if (annotator != null) { annotator.dispose(); } }

On this page