Add arrow annotation

On this page

Arrow annotation draws an arrow on the document page and annotate it as shown in the picture below. 

You can use the following methods to set the properties of the ArrowAnnotation class:

To add an arrow annotation to document, follow these steps:  

  1. Instantiate the Annotator class. Specify the input document path or stream.
  2. Instantiate the ArrowAnnotation class. Set the appropriate properties (position, page number, etc).
  3. Call the add() method. Specify the ArrowAnnotation class.
  4. Call the save() method. Specify the output document path or stream.

The following code snippet shows how to add ArrowAnnotation to the document:

// This example demonstrates adding arrow annotation.

// Create an instance of Annotator class
Annotator annotator = new Annotator("inputPath");
try {
    // Create an instance of Reply class and add comments
    Reply reply1 = new Reply();
    reply1.setComment("First comment");
    reply1.setRepliedOn(Calendar.getInstance().getTime());

    Reply reply2 = new Reply();
    reply2.setComment("Second comment");
    reply2.setRepliedOn(Calendar.getInstance().getTime());

    java.util.List<Reply> replies =  new ArrayList<Reply>();
    replies.add(reply1);
    replies.add(reply2);

    // Create an instance of ArrowAnnotation class and set options
    ArrowAnnotation arrow = new ArrowAnnotation();
    arrow.setBox(new Rectangle(100, 100, 100, 100));
    arrow.setCreatedOn(Calendar.getInstance().getTime());
    arrow.setMessage("This is arrow annotation");
    arrow.setOpacity(0.7);
    arrow.setPageNumber(0);
    arrow.setPenColor(65535);
    arrow.setPenStyle(PenStyle.Dot);
    arrow.setPenWidth((byte) 3);
    arrow.setReplies(replies);
    
    // Add annotation and save to file
    annotator.add(arrow);
    annotator.save("outputPath");
} finally {
    if (annotator != null) {
        annotator.dispose();
    }
}

On this page