4 Replies Latest reply on Jul 4, 2017 1:28 PM by tykez123

    Javascript Counter


      Hello I am new to Javascript and specifically Javascript + Adobe. At my jobs I use a lot of stamps in my pdf. I want to create a script, button, or tool that when clicked will count all the specific stamps in the document. Is there a way to do this or is there an easier way to go about counting my things on the document. Thank you

        • 1. Re: Javascript Counter
          try67 MVP & Adobe Community Professional

          What do you mean when you say that you want to count "specific" stamps? Do you mean only stamps of a certain kind, not all of them?

          It's possible either way, but the former is more complicated as you would need to first find out the unique identifier of that stamp type and then use it in your code.

          • 2. Re: Javascript Counter
            tykez123 Level 1

            So I have my document and as I am going through every so often I am stamping, but I  am using didn't stamps through out the process and at the end I want to hit a button or run a script and display text that would show the quantity of that certain stamp. Thank you for replaying

            • 3. Re: Javascript Counter
              try67 MVP & Adobe Community Professional

              You can do it using this code. You just need to select a stamp of the type that you want to count before running it:


              (function () {
                  if (this.selectedAnnots==null || this.selectedAnnots.length==0) {
                      app.alert("You must select a stamp first.");
                  var selectedAnnot = this.selectedAnnots[0];
                  var annots = this.getAnnots();
                  if (annots==null || annots.length==0) {
                      app.alert("There are no comments in this file.");
                  var counter = 0;
                  for (var i in annots) {
                      if (annots[i].type=="Stamp" && annots[i].AP==selectedAnnot.AP) {
                  app.alert("There are " + counter + " stamps of this type in this file.",3);


              The code can be executed from the Console, or even from an Action or a menu-item (the latter will require placing it in a folder-level script, though).

              1 person found this helpful
              • 4. Re: Javascript Counter
                tykez123 Level 1

                Right on man. Thank you so much for your help! I manually do this task with projects all day long and it can become a pain in the butt day after day.