GroupDocs.Annotation allows you to update annotations by specifying their Id properties. Also you can update annotations by providing a collection of updated annotation objects that replaces all existing document annotations.
To update annotations, follow these steps:
Instantiate the Annotator class. Specify the input document path or stream.
Create an AnnotationBase implementation and set Id of existed annotation (if annotation with that Id is not found, it is ignored) or path list of annotations (all existed annotations are removed).
Call the Update method of the Annotator class. Specify annotations.
Call the Save method. Specify the output document path or stream.
The following code demonstrates how to update annotations:
using(Annotatorannotator=newAnnotator("input.pdf")){AreaAnnotationoriginal=newAreaAnnotation{Id=1,BackgroundColor=65535,Box=newRectangle(100,100,100,100),CreatedOn=DateTime.Now,Message="This is original annotation",Replies=newList<Reply>{newReply{Comment="Original first comment",RepliedOn=DateTime.Now},newReply{Comment="Original second comment",RepliedOn=DateTime.Now}}};// add original annotationannotator.Add(original);annotator.Save("result.pdf");}// open annotated documentusing(Annotatorannotator=newAnnotator("result.pdf")){//assuming we are going to change some properties of existing annotationAreaAnnotationupdated=newAreaAnnotation{// It's important to set existed annotation IdId=1,BackgroundColor=255,Box=newRectangle(0,0,50,200),CreatedOn=DateTime.Now,Message="This is updated annotation",Replies=newList<Reply>{newReply{Comment="Updated first comment",RepliedOn=DateTime.Now},newReply{Comment="Updated second comment",RepliedOn=DateTime.Now}}};// update annotationannotator.Update(updated);annotator.Save("result.pdf");}
You can also update annotation using Id. You can also pass the list of annotations. In that case all previous annotations will be replaced by new list.
To do this, follow these steps:
Instantiate the Annotator class. Specify the input document path or stream.
Create an AnnotationBase implementation and set Id of existed annotation (if annotation with that Id is not found, it is ignored) or path list of annotations (all existed annotations will be removed).
Call the Update method of the Annotator class. Specify annotations.
Call the Save method. Specify the output document path or stream.
The following code demonstrates how to update annotations using Id:
using(Annotatorannotator=newAnnotator("input.pdf")){AreaAnnotationoriginal=newAreaAnnotation{Id=1,BackgroundColor=65535,Box=newRectangle(100,100,100,100),CreatedOn=DateTime.Now,Message="This is original annotation",Replies=newList<Reply>{newReply{Comment="Original first comment",RepliedOn=DateTime.Now},newReply{Comment="Original second comment",RepliedOn=DateTime.Now}}};// add original annotationannotator.Add(original);annotator.Save("result.pdf");}// open annotated documentusing(Annotatorannotator=newAnnotator("result.pdf")){//assuming we are going to change some properties of existing annotationAreaAnnotationupdated=newAreaAnnotation{// It's important to set existed annotation IdId=1,BackgroundColor=255,Box=newRectangle(0,0,50,200),CreatedOn=DateTime.Now,Message="This is updated annotation",Replies=newList<Reply>{newReply{Comment="Updated first comment",RepliedOn=DateTime.Now},newReply{Comment="Updated second comment",RepliedOn=DateTime.Now}}};// update annotationannotator.Update(updated);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.