Remove annotation replies

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 →

You can remove specific or all replies using the GroupDocs.Annotation API. To do this, remove the appropriate items from the List<T> collection.

To delete an annotation reply (replies), follow these steps:

  1. Instantiate the Annotator class. Specify the input document path or stream.
  2. Call the get() method of the Annotator class to get collection of document annotations.
  3. Access the appropriate annotation and remove a reply in a suitable way: * call the annotations.get(index).getReplies().remove(index) method. Specify approptiate parameters; * call the AnnotationBase.getReplies() method and remove replies that match desired criteria.
  4. Call the update method of the Annotator class. Specify the annotations collection.
  5. Call the save() method. Specify the output document path or stream.

Remove specific annotation reply 

The following code snippet shows how to remove annotation reply by its index:

// This example demonstrates how to remove replies from annotated document by reply Id.

LoadOptions tmp0 = new LoadOptions();

// NOTE: Input document already contain annotations with replies
final Annotator annotator = new Annotator("inputPath", tmp0);
try {
    // Obtain annotations collection from document
    List<AnnotationBase> annotations = annotator.get();

    // Remove reply with Id = 4
    annotations.get(0).getReplies().remove(4);

    // Update and save changes
    annotator.update(annotations);
    annotator.save("outputPath");
} finally {
    if (annotator != null) {
        annotator.dispose();
    }
}

Remove annotation replies by criteria

The following code snippet shows how to remove replies that match some criteria:

// This example demonstrates how to remove replies from annotated document by user name.

LoadOptions tmp0 = new LoadOptions();

// NOTE: Input document already contain annotations with replies
Annotator annotator = new Annotator("inputPath", tmp0);
try {
    // Obtain annotations collection from document
    List<AnnotationBase> annotations = annotator.get();

    // Remove all replies where author name is "Tom"           
    for(int i = 0; i < annotations.get(0).getReplies().size(); i++) {
        if(annotations.get(0).getReplies().get(i).getUser().getName().toString().equals("Tom")) {
            annotations.get(0).getReplies().remove(i);
        }
    }

    // Update and save changes
    annotator.update(annotations);
    annotator.save("outputPath");
} finally {
    if (annotator != null) {
        annotator.dispose();
    }
}