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:
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 annotations.get(index).getReplies().remove(index) method. Specify approptiate parameters;
* call the AnnotationBase.getReplies() method and remove replies that match desired criteria.
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:
// This example demonstrates how to remove replies from annotated document by reply Id.
LoadOptionstmp0=newLoadOptions();// NOTE: Input document already contain annotations with replies
finalAnnotatorannotator=newAnnotator("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.
LoadOptionstmp0=newLoadOptions();// NOTE: Input document already contain annotations with replies
Annotatorannotator=newAnnotator("inputPath",tmp0);try{// Obtain annotations collection from document
List<AnnotationBase>annotations=annotator.get();// Remove all replies where author name is "Tom"
for(inti=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();}}
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.