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:
Instantiate the Annotator class. Specify the input document path or stream.
Call the Get method of the Annotator class to get collection of document annotations.
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.
Call the Update method of the Annotator class. Specify the annotations collection.
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 repliesusing(Annotatorannotator=newAnnotator("result.pdf")){// Obtain annotations collection from documentList<AnnotationBase>annotations=annotator.Get();// Remove first reply annotations[0].Replies.RemoveAt(0);// Save changesannotator.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 repliesusing(Annotatorannotator=newAnnotator("annotated_file_with_replies.pdf")){// Obtain annotations collection from documentList<AnnotationBase>annotations=annotator.Get();// Remove all replies where author name is "Tom"annotations[0].Replies.RemoveAll(x=>x.User.Name=="Tom");// Save changesannotator.Update(annotations);annotator.Save("result.pdf");}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.