Annotations

Use a PdfDocument object's AnnotationManager, along with the AnnotationOptions class, to add "sticky note"-style annotations to specified pages of a PDF document.

Create a text-based annotation at a given location on a page by specifying the text and the cartesian (x,y) coordinates as arguments in an AnnotationOption constructor, as shown in the code example above. Next, invoke the addTextAnnotation method on the AnnotationManager to add the annotation to the desired page in the working PDF document. 

Additional methods on every AnnotationOptions object enable developers to customize an annotation's appearance and behavior. In the above code example, we set its opacity and featured icon, as well as set it to not be editable or printable. Developers can also change the color, height, and title of an annotation, as well as its title, subject, content, and location.

Steps to create Annotation in PDF using Java

  1. Install Java library to add annotations to PDF
  2. Utilize PdfDocument class to load existing PDF file in Java
  3. Create and customize annotations with AnnotationOptions class
  4. Use addTextAnnotation to add annotations to specific pages of PDF
  5. Export PDF document containing annotations