Every annotation can carry a discussion thread. You build the thread as a list of Reply objects and assign it to the annotation’s replies property. Each reply has a comment and a User, and each user has a name and a Role (Role.EDITOR or Role.VIEWER).
Add replies to an annotation
The example below creates an area annotation and attaches a two-message conversation between two users before saving the document.
fromgroupdocs.annotationimportAnnotatorfromgroupdocs.annotation.modelsimportRectangle,Reply,User,Rolefromgroupdocs.annotation.models.annotation_modelsimportAreaAnnotationfromgroupdocs.pydrawingimportColordefadd_replies_to_annotation():withAnnotator("./sample.pdf")asannotator:area=AreaAnnotation()area.box=Rectangle(100,100,100,100)area.background_color=Color.yellow.to_argb()area.page_number=0area.message="Please review this section"# Attach a threaded discussion to the annotationfirst_reply=Reply()first_reply.comment="Good catch, I'll take a look."first_reply.user=User(name="Tom",role=Role.EDITOR)second_reply=Reply()second_reply.comment="Agreed, looks resolved now."second_reply.user=User(name="Jack",role=Role.VIEWER)area.replies=[first_reply,second_reply]annotator.add(area)annotator.save("./output.pdf")if__name__=="__main__":add_replies_to_annotation()
sample.pdf is the sample file used in this example. Click here to download it.