Add squiggly annotation

On this page

Squiggly annotation marks text with a squiggly styling as shown in the picture below:

You can specify the following properties of the SquigglyAnnotation class:

  • FontColor defines the color of the annotation text
  • Opacity allows you to set the annotation opacity
  • Points defines the annotation positions as array of points
  • BackgroundColor defines the area background color
  • SquigglyColor defines the annotation line color

To add a squiggly annotation, follow these steps:

  1. Instantiate the Annotator class. Specify the input document path or stream.
  2. Instantiate the SquigglyAnnotation class. Specify the appropriate properties (position, page number, etc).
  3. Call the Add method. Specify the SquigglyAnnotation class;
  4. Call the Save method. Specify the output document path or stream.

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

//Add squiggly annotation to the document from local disk
try(final Annotator annotator = new Annotator("input.pdf")){
	SquigglyAnnotation squigglyAnnotation = new SquigglyAnnotation();
	squigglyAnnotation.setCreatedOn(new Date());
	squigglyAnnotation.setFontColor(65535);
	squigglyAnnotation.setBackgroundColor(16761035);
	squigglyAnnotation.setMessage("This is squiggly annotation");
	squigglyAnnotation.setOpacity(0.7);
	squigglyAnnotation.setPageNumber(0);
	squigglyAnnotation.setSquigglyColor(1422623);//Supported only Word and PDF
	List points = new ArrayList<Point>();
	points.add(new Point(80, 730));
	points.add(new Point(240, 730));
	points.add(new Point(80, 650));
	points.add(new Point(240, 650));

	Reply reply1 = new Reply();
	reply1.setComment("First comment");
	reply1.setRepliedOn(new Date());

	Reply reply2 = new Reply();
	reply2.setComment("Second comment");
	reply2.setRepliedOn(new Date());

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

	squigglyAnnotation.setReplies(replies);

	annotator.add(squigglyAnnotation);
	annotator.save("result_squiggly_annotation.pdf");
}

On this page