Search code examples
pdfannotations

How to check multiple PDF files for annotations/comments?


Problem: I routinely receive PDF reports and annotate (highlight etc.) some of them. I had the bad habit of saving the annotated PDFs together with the non-annotated PDFs. I now have hundreds of PDF files in the same folder, some annotated and some not. Is there a way to check every PDF file for annotations and copy only the annotated ones to a new folder?

Thanks a lot!

I'm on Win 7 64bit, I have Adobe Acrobat XI installed and I'm able to do some beginner coding in Python and Javascript


Please ignore the following suggestion, since the answers already solved the problem.

EDIT: Following Mr. Wyss' suggestion, I created the following code for Acrobat's Javascript console to be run only once at the beginning:

counter = 1;

// Open a new report
var rep = new Report();
rep.size = 1.2;
rep.color = color.blue;
rep.writeText("Files WITH Annotations");

Then this code should be applied to all PDFs:

this.syncAnnotScan();
annots = this.getAnnots();
path = this.path;
if (annots) {
    rep.color = color.black;
    rep.writeText(" ");
    rep.writeText(counter.toString()+"- "+path);
    rep.writeText(" ");
    if (counter% 20 == 0) {
        rep.breakPage();
    }
    counter++;
}

And, at last, one code to be run only once at the end:

//Now open the report
var docRep = rep.open("files_with_annots.pdf");

There are two problems with this solution:

1. The "Action Wizard" seems to always apply the same code afresh to each PDF (that means that the "counter" variable, for instance, is meaningless; it will always be = 1. But more importantly, var "rep" will be unassigned when the middle code is run on different PDFs). 2. How can I make the codes that should be run only once run only at the beginning or at the end, instead of running everytime for every single PDF (like it does by default)?

Thank you very much again for your help!


Solution

  • This would be possible using the Action Wizard to put together an action.

    The function to determine whether there are annotations in the document would be done in Acrobat JavaScript. Roughly, the core function would look like this:

    this.syncAnnotScan() ; // updates all annots
    var myAnnots = this.getAnnots() ;
    if (myAnnots != null) {
    // do something if there are annots
    } else {
    // do something if there are no annots
    }
    

    And that should get you there.

    I am not completely positive, but I think there is also a Preflight check which tells you whether there are annotations in the document. If so, you would create a Preflight droplet, which would sort out the annotated and not annotated documents.