2

Is it possible to get the author of a free text annotation using iText?

I have the TYPE and CONTENTS, but can see noway to get the author

john renfrew
  • 393
  • 1
  • 9
  • 30

3 Answers3

4

Please consult ISO-32000-1 table 170 "Additional entries specific to markup annotations". It defines a key named /T that is described as an optional text string that shall be displayed in the title bar of the annotation's pop-up window when open and active. This entry shall identify the user who added the annotation.

KenS is correct in the sense that the value you seek is not available for every type of annotations, but if the author is present, you'll find it in the /T entry.

So when you have this in Adobe Acrobat:

enter image description here

You'll find this inside the PDF:

enter image description here

You already have the /Contents and /Type entry, now you should also look for the /T entry. If it is missing, the author of the annotation can not be retrieved.

These are some examples on how to get specific keys from an annotation:

I'm adding these links only for the sake of completeness, I think you already know the concept:

PdfDictionary annotDict = annots.getAsDict(i);
PdfName author = annotDict.getAsString(PdfName.T);

If author is null, the author can not be retrieved.

Community
  • 1
  • 1
Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
  • thank you.. as ever your detailed knowledge shows it's worth. I had read the tables from 171 so missed what is now clear as the blindingly obvious. – john renfrew Mar 01 '15 at 16:50
0

While you can specify extra keys in a dictionary, which will usually be ignored, there is no 'Author' key in an annotation or FreeText annotation in the specification.

So you can't get the author of a FreeText annotation, because its not normally part of an annotation.

KenS
  • 30,202
  • 3
  • 34
  • 51
0

Please use the T key like so

PdfString Author = annot.GetAsString(PdfName.T);
Mnyikka
  • 1,223
  • 17
  • 12