Skip to main content
Skip table of contents

How to get the author of a "free text" annotation?

Is it possible to get the author of a free text annotation using iText? I can retrieve the /Type and /Contents, but I can't find a way to get the author.

Posted on StackOverflow on Feb 28, 2015 by john renfrew

If the author value is present, you'll find it in the /T entry. 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. The value you seek is not available for every type of annotations, only for markup annotations.

So when you have this in Adobe Acrobat:

Annotations in a PDF

Annotations in a PDF

You'll find this inside the PDF:

Annotations in iText RUPS

Annotations in iText RUPS

In iText 7 you should look for the /Annots entry using getAnnotations() method. Each annotation has a getTitle() method, so it's really easy to solve your problem:

public void manipulatePdf(String src, String dest) throws IOException {
    PdfDocument pdfDoc = new PdfDocument(new PdfReader(src), new PdfWriter(dest));
    List annots = pdfDoc.getFirstPage().getAnnotations();
    if (annots != null) {
        for (PdfAnnotation a : annots) {
            if (a.getTitle() != null)
                System.out.println(a.getTitle());
        }
    }
    pdfDoc.close();
}

Click this link if you want to see how to answer this question in iText 5.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.