Save only annotated pages

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Annotation MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-annotation -- dnx GroupDocs.Annotation.Mcp --yes
Folders, licensing and more →

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