Why the script has to be run twice?
Hi,
I am writing a script to spell-check PDF. With reference to the official API document here, the script is copied as a js file to Acrobat javascript folder. I also add a line to insert a menu item to run the script:
app.addMenuItem({cName: "&Spell Check All Pages", cParent: "Edit", nPos: 0, cExec: "testck();", cEnable: "event.rc = (event.target != null)"});
function testck() {
var ckWord, 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()
});
}
}
}
}
However, the strange thing I encountered is that when I click the item in the menu in first time, it doesn't complete. When I click the second time, it runs completely and show the result. Afterwards, it run completely by just one click. If I close the Acrobat and restarts, it requires a double execution. Would you please help indicate the problem? Thank you!!
Geoff
