Copy link to clipboard
Copied
Hello,
I'm not experienced in Adobe JavaScript but recently I've faced a problem: is there a way to automatically count all types of comments in one document opened with Adobe Acrobat Reader Pro? I even found a JavaScript on the internet. Unfortunately it counts only one type of the comments:
var counter = 0;
var annots = this.getAnnots();
for (var i = 0; i < annots.length; i++) {
if (annots[i].type == "Text") {
counter++;
}
}
app.alert("Total comments count: " + counter);
Thank You in advance for help.
The easiest solution is to print out the number of comments to the console, and at the end of the process copy it from there.
You can use this code for that:
this.syncAnnotScan();
var annots = this.getAnnots();
console.println(this.documentFileName + ": " + ((annots==null) ? 0 : annots.length));
Copy link to clipboard
Copied
Sure, it's possible. Use this code:
this.syncAnnotScan();
var annots = this.getAnnots();
app.alert("Total comments count: " + (annots==null) ? 0 : annots.length);
Copy link to clipboard
Copied
Hi try67, I'm a beginner in JavaScript, could You please give me a hint how to insert this code. If I do this my way Adobe Reader shows a Warning - picture below. I paste your code as it is with no additions in the "Document JavaScript" window.
Copy link to clipboard
Copied
Change the last line to:
app.alert("Total comments count: " + ((annots==null) ? 0 : annots.length));
Where to place it depends on when you want to run it...
Copy link to clipboard
Copied
Great, this code works. Do You think it is possible to create a script that counts the comments in many pdf's without opening them and exports number of comments of each file to a text file? It would save a time.
Copy link to clipboard
Copied
Yes, that's certainly possible, using Acrobat Pro.
Copy link to clipboard
Copied
Is there any script that could run this solution? And how?
Copy link to clipboard
Copied
The easiest solution is to print out the number of comments to the console, and at the end of the process copy it from there.
You can use this code for that:
this.syncAnnotScan();
var annots = this.getAnnots();
console.println(this.documentFileName + ": " + ((annots==null) ? 0 : annots.length));
Copy link to clipboard
Copied
Hello again,
try67 Your code works! But there is something wrong with it - I have opened 3 pdfs with different number of comments (eg. 9, 20 and 21). The console shows the correct number only for 2 of the documents, it always shows bigger by one number in one of the documents (eg. 9, 20 and 22). This action repeats every time, no matter what type of comments I put to the document.
Copy link to clipboard
Copied
Some comments are composed of two annotations. For example, the "Add Note To Replace Text" comment is a Strikethrough and a Caret. So in the final count it will count as two comments, not one.
Copy link to clipboard
Copied
OK, thank You very much!