How to extract comments along with the replies chain from pdf page?

For now, we can get the comments text from com.aspose.pdf.Annotation.getContents() method. But I want to know, how to get the reply chain for that comment and want to know which reply belongs to which parent.

Please provide some suggestions.

@nathiya1

Could you please share the sample PDF document for our reference? We will test the scenario in our environment and address it accordingly.

Hi @asad.ali,

Sorry for the delay.
Please find the PDF file here,
comments with replies.pdf (40.8 KB)

@nathiya1

Please check the below code snippet in order to get comments with their replies:

Document doc = new Document(dataDir + "comments with replies.pdf");
for(Page page : doc.getPages())
{
 for(com.aspose.pdf.Annotation annot : page.getAnnotations())
 {
  if(annot instanceof TextAnnotation)
  {
   TextAnnotation comment = (TextAnnotation)annot;
   String comment_content = comment.getContents();
   com.aspose.pdf.Annotation reply = comment.getInReplyTo();
   String reply_content = "";
   if(reply != null){
    reply_content = reply.getContents();
   }
   System.out.println("Comment : " + comment_content + " and reply : " + reply_content);
  }
 }
}

Thank you so much for this update.
We can have an another reply for a reply. Need to extract the comment as well as full reply chains. I want to know a way to get the full reply chains.

Can you guide me on this one?

@nathiya1

Thanks for your feedback.

If you check in the above code snippet, the comment.getInReplyTo() method returns an Annotation Class and you can get replies against that annotation as well by calling reply.getInReplyTo() method.