Find, Highlight and Delete Null Pages?
While trying to come up with a way to quickly reduce the size of large PDFs that are viewed on line, I thought I would highlight a key word on the pages I need and then delete pages without annotations. I decided to replace step 2 in the Find and Highlight Words action with my own script. The script I came up with, (my first ever) works fine on the 35 page document that I used to develop it:
var pageArray=[]
for (var i = 0; i < this.numPages; i++)
{
Aannots = this.getAnnots(i);
if (Aannots == null)
{
pageArray.push(i);
};
pageArray.sort();
pageArray.reverse();
}
for (var j = 0; j < pageArray.length; j++)
{
this.deletePages(pageArray
}
but when run on a very large, 2000+ page doc, it deletes some pages, then hangs or finishes with:
"TypeError: Invalid argument type.
Doc.deletePages:62:Batch undefined:Exec
===> Parameter nStart.""
in the console.
If I keep rerunning this code in the console, it eventually deletes all the unannotated pages.
Since the arguments come from the array, I print it out and am surprised that it is not in the reversed numerical order I expected.
Could that be the problem? or one of them?
Thanks for any help you can give . . . at 65, I don't know if I'll live long enough to figure this out myself!
