2

using iText I am able to get a list of annotations of a PDF. It seems that even replies are annotations themselves.

Extracting them, I look at the contents of the PdfDictionary using this

Set<PdfName> keys = annot.getKeys();
for (PdfName key : keys) {
    System.out.println(key + "," + dictionary.get(key));
}

However, I cannot pinpoint which PdfName I need to use in order to identify replies belong to that certain annotation.

chitgoks
  • 311
  • 2
  • 6
  • 17
  • The PDF specification does not know *reply annotations.* Thus, you probably are talking about a proprietary use of some annotations. Thus, please share a sample to inspect to clarify what is meant. – mkl Apr 29 '16 at 10:21
  • Hi @mkl see http://developers.itextpdf.com/question/how-add-reply-annotation – Bruno Lowagie Apr 29 '16 at 13:12
  • @BrunoLowagie Oops, I see, and it indeed is already PDF specification stuff... Never seen it before. – mkl Apr 30 '16 at 19:40

1 Answers1

2

Please take a look at the official documentation, more specifically at the answer to the example How to add an "In Reply To" annotation?

In this answer, I explain how to add an "In reply to" to an existing annotation. Let's open the resulting PDF and let's take a look inside:

enter image description here

As you can see, the annotation with the content "Hello PDF" is stored in an object with number 1. It is an annotation in reply to (IRT) the annotation with object number 2.

In answer to your question: you need to look at the key with value PdfName.IRT and this will give you the object number of the annotation to which the current number is a reply.

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
  • hi bruno, mkl. i managed to find out the annotation where pdfname.irt belongs to. i store the pdfname.n value from pdfname.ap dictionary of the annitation if the next annotation has pdfname.irt then i access the same pdfname.n from its pdfname.ap. i then loop through my annotations to get the annotation that has the same value of pdfname.n worked for me. thanks – chitgoks Apr 30 '16 at 10:45
  • @BrunoLowagie Could you please show how to set reference to the annotation using the object number obtained from the .IRT value? – Mech_Engineer Jan 14 '19 at 14:24