Copy link to clipboard
Copied
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;
}
1 Correct answer
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;
Copy link to clipboard
Copied
At the start of your for-loop insert this command:
if (a.page>39) continue;
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
Directly after this line:
for (var i = 0; i < a.length; i++) {
Copy link to clipboard
Copied
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;
}
Copy link to clipboard
Copied
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>
Copy link to clipboard
Copied
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..
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
That worked perfectly! Thank you so much!

