Copy link to clipboard
Copied
I was hoping that someone would be able to write a simple script for me. I am a teacher and grading pdf papers. I am using the check mark symbol under the "fill and sign". All I am looking for is a script that will just pop up a box that will tell me how many check marks I have placed on the document. Ideally I'd like to be able to amend the script to also count other characters from the fill and sign tool such as the cross or line. Is anybody able to assist me with this? Thank you very much.
Copy link to clipboard
Copied
This is not possible with Acrobat Javascript.
You should add form checkboxes to the form.
Copy link to clipboard
Copied
I think it is possible. Could you share a sample file with some of those check-marks, please?
Copy link to clipboard
Copied
Hi there try67
Thank you so much! I've shared an example below:
https://www.dropbox.com/sh/04qup72tvb49pm5/AABpaeTsZOkeo_iq616AQRRVa?dl=0
Copy link to clipboard
Copied
Sorry, it's not possible after all, since it's adding images, not comments or even textual characters.
If you used the Stamp tool instead, for example, then it will be possible.
Copy link to clipboard
Copied
Thanks so much. I could change to using the stamp tool if I can create a shortcut to a specific stamp. Let's say I use the default 'accepted' stamp or another custom stamp?
Copy link to clipboard
Copied
I've created a shortcut to the stamp I want to use and also am using the 'pin' to keep the stamp selected while I mark the paper. Now all I need is a script to count the stamps and pop up a box telling me how many I placed on the document. Can you help me with this? Thanks again
Copy link to clipboard
Copied
Sure, but can you upload a new sample file, please?
Copy link to clipboard
Copied
Uploaded to the same folder above. Thanks!
Copy link to clipboard
Copied
OK, then you can use this script to do it:
this.syncAnnotScan();
var counter = 0;
var annots = this.getAnnots();
if (annots!=null) {
for (var i in annots) {
var annot = annots[i];
if (annot.type=="Stamp" && annot.AP=="SHAccepted") counter++;
}
}
app.alert(counter + " check-marks were found in this file.",3);
You can attach it to a "Custom Command" or an Action, or even make it into a toolbar or menu item, although that's a bit more complicated.
Copy link to clipboard
Copied
Another way you can do it (maybe easier) is to open the Comments List and filter it by Type. Select "Stamp" and (assuming you didn't add stamps of a different kind) you could see the number of them in the header of that panel. If you only added this type of comment to the file then you don't even need to filter it...
Copy link to clipboard
Copied
Thanks so much! Both of these work. I've created an action with the javascript in it. One last question: I added a custom stamp with its own name. I tried to change the "SHAccepted" in the script to the name of my custom stamp but it isn't working. Is there a way to count my custom stamp and not just the 'Accepted' stamp?
Copy link to clipboard
Copied
You need to find the AP value of that stamp (which is not the same as the Stamp Name).
If you want to share a sample file I can let you know what it is, or I can explain how you could do it yourself via the JS Console.
Copy link to clipboard
Copied
If you could share how to do it via the console I'd appreciate it, because I'm hoping to create several stamps for different purposes. Thank you.
Copy link to clipboard
Copied
Sure. So after applying the stamp to the page, click it with the mouse to select it and then press Ctrl+J to open the JS Console. Paste the following code into it and then press Ctrl+Enter and it should print out the AP value for that stamp, which you can then use in your code:
this.selectedAnnots[0].AP
Copy link to clipboard
Copied
Excellent!
I couldn't figure out where it printed the AP name so I added the app.alert function and it worked.
Thanks again for your help.
Copy link to clipboard
Copied
It should be printed out in the JS Console itself, right after the code, but using an alert is a good idea, too!