Skip to main content
Skip table of contents

How to change the author name for comments?

Does anyone have a script which will change the name of the author whenever any markup such as underlining, highlighting, etc, is applied? You can do this manually through the properties box, but this is time consuming and difficult.

Posted on LinkedIn on Mar 19, 2015 by Paul Tredoux

Take a look at the changeauthor example. We take a PDF with annotations created by "iText" and turn it into a PDF with annotations created by "Bruno Lowagie".

The code is really simple: we loop over the annotations of a page and change the title (if it equals to "iText"). We use PdfDocument to persist the changed PDF.

protected void manipulatePdf(String dest) throws IOException {
    PdfDocument pdfDoc = new PdfDocument(new PdfReader(SRC), new PdfWriter(dest));

    List<PdfAnnotation> pageAnnots = pdfDoc.getFirstPage().getAnnotations();
    for (PdfAnnotation annot : pageAnnots) {
        if (annot.getTitle() != null) {
            annot.setTitle(new PdfString("Bruno Lowagie"));

Click How to change the author name for comments? 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.