Save only annotated pages

On this page

To export the annotated pages only, follow these steps:

  1. Instantiate the Annotator class. Specify the input document path or stream.
  2. Instantiate the SaveOptions class. Call the setOnlyAnnotatedPages to set the property to true.
  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 annotated pages:
// This example demonstrates saving result document with specified pages.

// Create an instance of Annotator class
Annotator annotator = new Annotator("inputPath");
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));
    ellipse.setBackgroundColor(123456);
    ellipse.setPageNumber(2);
    
    List<AnnotationBase> tmp0 = new ArrayList<AnnotationBase>();
    tmp0.add(area);
    tmp0.add(ellipse);
    
    // Add annotation and save to file
    annotator.add(tmp0);
    
    SaveOptions tmp1 = new SaveOptions();
    tmp1.setOnlyAnnotatedPages(true);
    
    annotator.save(outputPath, tmp1);
} finally {
    if (annotator != null) {
        annotator.dispose();
    }
}

On this page