This sample code shows how to get property information about reply to or grouped annotations annotations added to a PDF document. This functionality was open in the public API in v2017R1.1 in jPDFProcess library.

PDFPage p = pdfDoc.getPage(i);
Vector annots = p.getAnnotations();
if(annots != null)
{
  for(int count = 0; count < annots.size(); count++)
  {
	Annotation annot = annots.get(count);
	System.out.println("Annot Number " + (count + 1));
 
        // annotation type
	System.out.println("Type: " + annot.getSubtype());
 
	// annotation creator
	System.out.println("Creator: " + annot.getCreator());
 
	// annotation modified date
	System.out.println("Modified Date: " + annot.getModifiedDate());
 
	// annotation location on the page 
	System.out.println("Location: " + annot.getRectangle());
 
        // annotation subject
	System.out.println("Subject: " + annot.getSubject());
 
	// annotation contents (this is the note attached to the annotation)
	System.out.println("Content: " + annot.getContents());
 
       // Does this annotation have an IRT parent annotation? 
       // Have an IRT parent annotations means that:
       // a) this is a reply to annotation to the parent annotation 
       // or 
       // b) that this annotation is grouped with the parent annotation
	if(annot.getIRTAnnotation() != null)
	{
	  System.out.println("This annotation has an IRT parent annotation");
 
          // output the parent IRT annotation contents
	  System.out.println("Parent Annotation Contents " + annot.getIRTAnnotation().getContents());
 
	  // Is this a grouped annotation?
	  System.out.println("This is a Grouped Annotation " + annot.isIRTGroup());
 
	  // Is this a reply annotation?
	  System.out.println("This is a Reply Annotation " + !annot.isIRTGroup());							
	}
   }
}

Reply To Annotations

This is showing a reply to annotation to the main sticky note annotation (as shown in Adobe Reader).

Here is the output to the sample code above for these annotations:

Annot Number 1
Type: Text
Creator: Leila Holmann
Modified Date: Thu Aug 10 14:05:26 EDT 2017
Location: java.awt.geom.Rectangle2D$Double[x=342.17,y=41.860000000000014,w=18.0,h=18.0]
Subject: Sticky Note
Content: This is a sticky note contents
Annot Number 2
Type: Text
Creator: Leila Holmann
Modified Date: Thu Aug 10 14:05:39 EDT 2017
Location: java.awt.geom.Rectangle2D$Double[x=342.17,y=41.860000000000014,w=18.0,h=18.0]
Subject: Sticky Note
Content: This is a reply to the sticky note
This annotation has an IRT parent annotation
Parent Annotation Contents This is a sticky note contents
This is a Grouped Annotation false
This is a Reply Annotation true

Grouped Annotations

These 2 annotations as shown in a PDF viewer are grouped. Annotation that reads “Annotation Group 2” is grouped with annotation that reads “Annotation Group 1”, which is the parent IRT annotation.

This is the output to the sample code above for these annotations:

Annot Number 3
Type: FreeText
Creator: Leila Holmann
Modified Date: Thu Aug 10 14:24:37 EDT 2017
Location: java.awt.geom.Rectangle2D$Double[x=327.1,y=90.47000000000003,w=89.91999999999996,h=21.959999999999923]
Subject: Text Box
Content: Annot Group 1
Annot Number 4
Type: FreeText
Creator: Leila Holmann
Modified Date: Thu Aug 10 14:24:37 EDT 2017
Location: java.awt.geom.Rectangle2D$Double[x=385.77,y=119.31999999999994,w=85.50999999999999,h=21.460000000000036]
Subject: Text Box
Content: Annot Group 2
This annotation has an IRT parent annotation
Parent Annotation Contents Annot Group 1
This is a Grouped Annotation true
This is a Reply Annotation false