Articles Finder with a multi-dimensional array
Copy link to clipboard
Copied
Hi Acrobat users,
I need to finds all articles in any pdf document and highlight them as definite or indefinite.
I have written the source code, yet something is not working when I compile it.
Can you help me or clarify me where do I miss? Much appreciated for your time.
Am I making wrong in array or variable declaration?
- app.addToolButton({ cName: "ArticlesCheckFn", cExec: "myArticlesFn()", cLabel: "Articles Check", cTooltext: "Run Articles Check"});
- var myArticlesFn = app.truArticlesdFunction(function()
- {
- var numWords;
- var bfound = false;
- var F = ["a", "an", "the"];
- var R = ["Indefinite article - A", "Indefinite article - AN", "Definite article - THE"];
- var Articles = new Array(F,R);
- var lowerpagelimit = 0;
- var upperpagelimit = this.numPages;
- var proglimit = upperpagelimit - lowerpagelimit;
- var progress = app.thermometer;
- progress.duration = proglimit;
- progress.begin();
- for (var i = 0; i < this.numPages; i++)
- {progress.value = i;
- progress.text = "Processing page " + (i + 1);
- numWords = this.getPageNumWords(i);
- for(var j = 0; j < numWords; j++)
- {for (var k=0;k<4;k++)
- {if (this.getpageNthWord(i,j) == Articles
[0]) - {var annot = this.addAnnot ({page: i, type: "Highlight", quads: this.getPageNthWordQuads(i,j), author: "Articles Script", contents: Articles[0]
});}}} - progress.end();
- }});
Copy link to clipboard
Copied
Any error in the console? What is truArticlesdFunction?
Copy link to clipboard
Copied
Your indexes are off for the "Articles" array
Change the code to
{if (this.getpageNthWord(i,j) == Articles[0]
{var annot = this.addAnnot ({page: i, type: "Highlight", quads: this.getPageNthWordQuads(i,j), author: "Articles Script", contents: Articles[1]
The first index selects the list of articles or the list of article types. The second index selects the specific entry.
Use the Acrobat JavaScript Reference early and often