GroupDocs.Annotation allows you to update annotation replies by accessing them using the Replies collection.
To update annotation 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 the document annotations.
Access desired reply object via getReplies() method collection by its index (zero-based) and update its properties as needed.
Call the update method of the Annotator class. Specify annotations.
Call the save() method. Specify the output document path or stream and the SaveOptions class.
The following code snippet shows how to update reply by index:
// This example demonstrates how to update annotation.
// Create an instance of Annotator class
Annotatorannotator=newAnnotator("inputPath");try{// Create an instance of Reply class and add comments
Replyreply1=newReply();reply1.setComment("Original first comment");reply1.setRepliedOn(Calendar.getInstance().getTime());Replyreply2=newReply();reply2.setComment("Original second comment");reply2.setRepliedOn(Calendar.getInstance().getTime());java.util.List<Reply>replies=newArrayList<Reply>();replies.add(reply1);replies.add(reply2);// Create an instance of AreaAnnotation class and set options
AreaAnnotationoriginal=newAreaAnnotation();original.setId(1);original.setBackgroundColor(65535);original.setBox(newRectangle(100,100,100,100));original.setCreatedOn(Calendar.getInstance().getTime());original.setMessage("This is original annotation");original.setReplies(replies);// Add original annotation
annotator.add(original);// Save to file
annotator.save("outputPath");}finally{if(annotator!=null){annotator.dispose();}}LoadOptionstmp0=newLoadOptions();// Open annotated document
Annotatorannotator1=newAnnotator("outputPath",tmp0);try{// Create an instance of Reply class and add comments
Replyreply1=newReply();reply1.setComment("Updated first comment");reply1.setRepliedOn(Calendar.getInstance().getTime());Replyreply2=newReply();reply2.setComment("Updated second comment");reply2.setRepliedOn(Calendar.getInstance().getTime());java.util.List<Reply>replies=newArrayList<Reply>();replies.add(reply1);replies.add(reply2);// Suggest we want change some properties of existed annotation
AreaAnnotationupdated=newAreaAnnotation();updated.setId(1);updated.setBackgroundColor(255);updated.setBox(newRectangle(0,0,50,200));updated.setCreatedOn(Calendar.getInstance().getTime());updated.setMessage("This is updated annotation");updated.setReplies(replies);// update annotation
annotator1.update(updated);// Save to file
annotator1.save(outputPath);}finally{if(annotator1!=null){annotator1.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.