• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Articles Finder with a multi-dimensional array

Community Beginner ,
Feb 26, 2018 Feb 26, 2018

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();
  • }});
TOPICS
Acrobat SDK and JavaScript

Views

227

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 16, 2018 Apr 16, 2018

Copy link to clipboard

Copied

Any error in the console? What is truArticlesdFunction?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 16, 2018 Apr 16, 2018

Copy link to clipboard

Copied

LATEST

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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines