These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Batch searching and annotating

Fusweb
Registered: Sep 22 2007
Posts: 6

I have a large upcoming project where I have to search and replace a telephone number in over 1000 large pdf documents.

I have found a script that I would like to adapt in the Acrobat JS Guide - It highlights misspelt words with a squiggly:

/* Mark misspelled words with squiggle */
var chWord, numWords;
for (var i = 0; i < this.numPages; i++)
{
numWords = this.getPageNumWords(i);
for (var j = 0; j < numWords; j++) {
ckWord = spell.checkWord(this.getPageNthWord(i,j))
if (ckWord != null) {
this.addAnnot({
page: i,
type: "Squiggly",
quads: this.getPageNthWordQuads(i,j),
author: "A.C.Acrobat",
contents: ckWord.toString()
});
}
}
}

I have replaced the section that spellchecks the word with a specific lookup (for the telephone no code that is changing:

/* Mark misspelled words with squiggle */
var chWord, numWords;
for (var i = 0; i < this.numPages; i++)
{
numWords = this.getPageNumWords(i);
for (var j = 0; j < numWords; j++) {

if ((this.getPageNthWord(i,j))=="0800") {
this.addAnnot({
page: i,
type: "Squiggly",
quads: this.getPageNthWordQuads(i,j),
author: "A.C.Acrobat",
contents: ckWord.toString()
});
}
}
}

This code does not work (I have tried numerous options over the last few weeks) but I cannot for the life of me work out why not. Any pointers please would be most appreciated.

Fusweb
Registered: Sep 22 2007
Posts: 6
Sussed it.

I still had some code from the previous routine which was causing an error:

contents: ckWord.toString()

Once deleted it works like a dream. Certainly better than reading 1000 policy documents tp find 0800 telephone numbers!