Remove annotation replies
There is a quick and convenient way to remove specific or even all replies for some document annotation using GroupDocs.Annotation API. It is as easy as removing items from generic List
- Instantiate Annotator object with input document path or stream;
- Call Get method of Annotator object and obtain collection of document annotations;
- Access desired annotation object and remove reply in a most suitable way:
- call RemoveAt(Int32) or Remove(T) method to remove specific reply;
- call RemoveAll(Predicate
) method to remove all replies that match the conditions defined by the specified predicate;
- Call Update method of Annotator object and pass annotations collection into it;
- Call Save method with resultant document path or stream;
Remove specific annotation reply
The easiest way for removing specific annotation reply is to delete by its index inside Replies collection. The following code sample demonstrates how to remove first annotation reply:
// 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
GroupDocs.Annotation API also provides a way to remove multiple annotation replies that match some criteria. The following code demonstrates how to remove replies that were added by user with name “Tom”:
// 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");
}
More resources
Advanced Usage Topics
To learn more about document annotating features, please refer to the advanced usage section.
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples:
- GroupDocs.Annotation for .NET examples, plugins, and showcase
- GroupDocs.Annotation for Java examples, plugins, and showcase
- Document Annotation for .NET MVC UI Example
- Document Annotation for .NET App WebForms UI Modern Example
- Document Annotation for Java App Dropwizard UI Modern Example
- Document Annotation for Java Spring UI Example
Free Online App
Along with full-featured .NET library we provide simple but powerful free Apps. You are welcome to annotate your PDF, DOC or DOCX, XLS or XLSX, PPT or PPTX, PNG and other documents with free to use online GroupDocs Annotation App.