Remove annotation replies

You can remove specific or all replies using the GroupDocs.Annotation API. To do this, remove the appropriate items from the List 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 RemoveAt(Int32) or Remove(T) method to remove specific reply; * call the RemoveAll(Predicate) method to remove all replies that match the conditions defined by the predicate.
  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:

// NOTE: Input document already contain annotations with replies
using (Annotator annotator = new Annotator("result.pdf"))
{
    // Obtain annotations collection from document
    List<AnnotationBase> annotations = annotator.Get();               
	// Remove first reply 
	annotations[0].Replies.RemoveAt(0);
	// Save changes
	annotator.Update(annotations);
	annotator.Save("result.pdf");
}

Remove annotation replies by criteria

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

// NOTE: Input document already contain annotations with replies
using (Annotator annotator = new Annotator("annotated_file_with_replies.pdf"))
{
    // Obtain annotations collection from document
    List<AnnotationBase> annotations = annotator.Get();
    // Remove all replies where author name is "Tom"
    annotations[0].Replies.RemoveAll(x => x.User.Name == "Tom");
    // Save changes
    annotator.Update(annotations);
    annotator.Save("result.pdf");
}