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

Scripting a Comment Summary Report with option to select page ranges

New Here ,
Mar 24, 2016 Mar 24, 2016

Hello everyone,

I am using Adobe Acrobat X Pro on Window 7.

I am a newbie to JavaScript but have been using the following script (actually found on this great forum!) to create a PDF Comment Summary Report.

It works great, but I would like to be able to include a line of code to select only specific page ranges (1-40) as I am working with a PDF with 700 pages and want to create a Summary Report for specific chapters. I tried inserting a code for printing specific pages, but when I used Ctrl-Enter to run the script it would just bring up the Print window.


Any help would be appreciated.

Thank you!

this.syncAnnotScan();

var a = this. getAnnots({nSortBy:ANSB_Page});

if (a) {

  var rep = new Report();

  rep.size = 1.8;

  rep.color = color.blue;

  rep.writeText("Summary of Comments for " + this.documentFileName);

  rep.color = color.black;

  rep.writeText(" ");

  rep.size = 1.2;

  rep.writeText("Total of " + a.length + " comments in this file");

  rep.writeText(" ");

  rep.writeText(" ");

  rep.indent(20);

  var msg = "\200 page %s by %s on %s";

  for (var i = 0; i < a.length; i++) {

    rep.writeText(" ");

   rep.indent(20);

    rep.writeText(a.contents);

    rep.outdent(20);

  }

  var docReport = rep.open("commentSummary.pdf");

docReport.info.Title = "Comments Summary for " + this.documentFileName;

}

TOPICS
Acrobat SDK and JavaScript , Windows
1.2K
Translate
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

correct answers 1 Correct answer

Community Expert , Mar 24, 2016 Mar 24, 2016

You'll need to add more conditions or adjust that one, for example to achieve the range you specified above (notice the page numbers in the code are zero-based):

if (a.page<80 || a.page>117) continue;

Translate
Community Expert ,
Mar 24, 2016 Mar 24, 2016

At the start of your for-loop insert this command:

if (a.page>39) continue;

Translate
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
New Here ,
Mar 24, 2016 Mar 24, 2016

Thanks try67, but as a newbie, can you please show me exactly where I would insert this command? Don't know for-loop from fruit-loop! LOL!

Translate
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 ,
Mar 24, 2016 Mar 24, 2016

Directly after this line:

for (var i = 0; i < a.length; i++) {

Translate
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
New Here ,
Mar 24, 2016 Mar 24, 2016

Hello again try67,

Inserted code where you indicated (see bolded code) and used this script via Ctrl-J/Ctrl-Enter and received the following message:

SyntaxError: syntax error

1:Console:Exec

undefined

this.syncAnnotScan();

var a = this. getAnnots({nSortBy:ANSB_Page});

if (a) {

  var rep = new Report();

  rep.size = 1.8;

  rep.color = color.blue;

  rep.writeText("Summary of Comments for " + this.documentFileName);

  rep.color = color.black;

  rep.writeText(" ");

  rep.size = 1.2;

  rep.writeText("Total of " + a.length + " comments in this file");

  rep.writeText(" ");

  rep.writeText(" ");

  rep.indent(20);

  var msg = "\200 page %s by %s on %s";

  for (var i = 0; i < a.length; i++) {

  if (a.page>39) continue;

    rep.writeText(" ");

   rep.indent(20);

    rep.writeText(a.contents);

    rep.outdent(20);

  }

  var docReport = rep.open("commentSummary.pdf");

docReport.info.Title = "Comments Summary for " + this.documentFileName;

}

Translate
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 ,
Mar 24, 2016 Mar 24, 2016

Did you select then entire code with the mouse before executing it?

On Thu, Mar 24, 2016 at 8:49 PM, sandymadobe <forums_noreply@adobe.com>

Translate
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
New Here ,
Mar 24, 2016 Mar 24, 2016

Yes, I was selecting the entire code before executing it, however,   I just closed the PDF file and executed the script again and it worked!

Now, I am going to bug you one more time and ask what line of code I'd use to select different ranges of pages?

For example: Page 81 to 118

Thanks again..

Translate
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 ,
Mar 24, 2016 Mar 24, 2016

You'll need to add more conditions or adjust that one, for example to achieve the range you specified above (notice the page numbers in the code are zero-based):

if (a.page<80 || a.page>117) continue;

Translate
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
New Here ,
Mar 24, 2016 Mar 24, 2016
LATEST

That worked perfectly! Thank you so much!

Translate
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