Instantiate the annotation object of the appropriate type. Available annotation types are listed here.
Assign the User class to Reply.User property (by default it is “Guest”).
Assign the Reply class(es) to the Replies collection created at previous steps.
Call the add() method of the Annotator class. Specify the annotation.
Call the save() method. Specify the output document path or stream.
The following code snippet shows how to add replies to annotation:
// This example demonstrates adding replies to annotation.
// Create an instance of Annotator class
Annotatorannotator=newAnnotator("inputPath");try{// Create an instance of User class and add data
Useruser1=newUser();user1.setId(1);user1.setName("Tom");user1.setEmail("somemail@mail.com");Useruser2=newUser();user2.setId(2);user2.setName("Jack");user2.setEmail("somebody@mail.com");Useruser3=newUser();user3.setId(3);user3.setName("Mike");user3.setEmail("somemike@mail.com");// Create an instance of AreaAnnotation class and set options
AreaAnnotationarea=newAreaAnnotation();area.setBackgroundColor(65535);area.setBox(newRectangle(100,100,100,100));area.setCreatedOn(Calendar.getInstance().getTime());area.setMessage("This is area annotation");area.setOpacity(0.7);area.setPageNumber(0);area.setPenColor(65535);area.setPenStyle(PenStyle.Dot);area.setPenWidth((byte)3);// Create an instance of Reply class and add comments
Replyreply1=newReply();reply1.setId(1);reply1.setComment("First comment");reply1.setRepliedOn(Calendar.getInstance().getTime());reply1.setUser(user1);Replyreply2=newReply();reply2.setId(2);reply2.setComment("Second comment");reply2.setRepliedOn(Calendar.getInstance().getTime());reply2.setUser(user2);Replyreply3=newReply();reply3.setId(3);reply3.setComment("Third comment");reply3.setRepliedOn(Calendar.getInstance().getTime());reply3.setUser(user1);Replyreply4=newReply();reply4.setId(4);reply4.setComment("Fourth comment");reply4.setRepliedOn(Calendar.getInstance().getTime());reply4.setUser(user2);Replyreply5=newReply();reply5.setId(5);reply5.setComment("Five comment");reply5.setRepliedOn(Calendar.getInstance().getTime());reply5.setUser(user3);java.util.List<Reply>replies=newArrayList<Reply>();replies.add(reply1);replies.add(reply2);replies.add(reply3);replies.add(reply4);replies.add(reply5);area.setReplies(replies);// Add annotation and save to file
annotator.add(area);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.