How to identify documents with Annotations and remove all of the annotations?

I wonder if JavaScript can identify documents with Annotations and remove all of the annotations. I'd like to execute the JavaScript codes in "Advanced - Document Processing - Batch Processing" to process documents in batch.

I check the "JavaScript for Acrobat API Reference" and find that there are methods "getAnnot" and "addAnnot", I'm not sure if there is a method to remove the annotations.

Your help is really appreciated!


xianghualeeandy


3 Answers

Voted Best Answer

In addition to David's answer, yes, this can be done with JavaScript as well.
You can use the getAnnots() method of the Document object to retrieve the annotations, and if that array is not empty you can iterate over it, calling the destory() method for each Annotation object to remove it.

So something like this:
this.syncAnnotScan();
var annots = this.getAnnots();
if (annots!=null && annots.length!=0)
for (var i in annots) annots[i].destroy();


By Gilad D (try67)   

Acrobat Pro (8, 9, X) includes a Preflight that will remove annotations.
Try using a Batch Process that makes use of this Preflight profile.


David Austin   

Look in the "Actions Exchange" on this site, there is a "Sort commented files" actions. This one could be modified to remove the annots from all docs in a folder.

And, as David said, Preflight contains a feature for removing annotations. As it happens, JavaScript can run a named preflight profile. So this is one very simple way to automate removing the annots.

Thom Parker
The source for PDF Scripting Info pdfscripting.com

The Acrobat JavaScript Reference, Use it Early and Often

The most important JavaScript Development tool in Acrobat
The Console Window (Video tutorial)
The Console Window(article)

Having trouble, Why Doesn't my Script Work


Thom Parker   


Please specify a reason: