Skip to main content
ramalingamkb
Participant
February 26, 2018
Question

Articles Finder with a multi-dimensional array

  • February 26, 2018
  • 2 replies
  • 406 views

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();
  • }});
This topic has been closed for replies.

2 replies

Thom Parker
Community Expert
Community Expert
April 17, 2018

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.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Bernd Alheit
Community Expert
Community Expert
April 17, 2018

Any error in the console? What is truArticlesdFunction?