7 Replies Latest reply on Jun 23, 2010 7:42 AM by DimitriM

    Alphabetical stamps

    Synergy_M Level 1

      Hi

       

      To reference previous documents, we often have to label each paragraph in a PDF with a letter in alphabetical order. So the first paragraph is A, the second is B and so on throughout the document. After Z the next paragraph is AA, then BB etc.

       

      We have to do this to several documents and we currently use text boxes, but this is laborious and if we could do this using dynamic stamps it would make life much easier. Is it possible to script a dynamic stamp with a form field so that the first time you use it in a document it will have an A, the next time a B, etc.?

       

      I thought maybe this could be done by linking the form to a database with each letter as a subsequent record, or just doing it using a script, but I have very limited javascript knowledge and no idea where to start!

       

      Any help would be appreciated. Thanks!

       

      Luke    

        • 1. Re: Alphabetical stamps
          DimitriM Level 3

          Hi Luke,

           

          Yes you can do this with custom dynamic stamps.  Dynamic stamps are super useful for just this type task.  We just published a free video "PDF Stamps Gone Wild!" yesterday on this very topic.  You can view it at www.pdfscripting.com under the Featured Video section.

           

          In addition to showing numerous ways dynamic stamps can be used,  the video demonstrates an example using a stamp to increment either numbers or letters, and of course you could customize such a stamp to go to AA, BB, etc after going thorugh the alphabet.  In addition, you can add an input dialog to the stamp so the user can choose which number or letter to begin with.

           

          And of course- all the magic is accomplished with Acrobat JavaScript.

           

          Hope this helps,

           

          Dimitri

          WindJack Solutions, Inc

          www.pdfscripting.com

          www.windjack.com

          • 3. Re: Alphabetical stamps
            DimitriM Level 3

            Yes, one of our examples in the video is based on Rick Borstein's Exhibit stamps for the legal field- but we added the ability to select letters and increment to AA, BB after A-Z  ( we give credit to him in the video for the original idea).

             

            Really nice tool for the legal field.

             

            Dimitri

            WindJack Solutions

            www.windjack.com

            www.pdfscripting.com

            • 4. Re: Alphabetical stamps
              Synergy_M Level 1

              Hi Dimitri

               

              Thanks, that does look like exactly what we need. I presume I have to be a member to download these scripts?

               

              Also, I am interested in how easy these are to customise – I presume the design will just be a case of editing the dynamic stamp PDF, but it would be useful to also be shown how to customise the scripts as well (e.g. the custom toolbar you show in the video) as there are a couple of other applications where I think this could be useful from what you show in the video.

               

              Cheers

               

              Luke

              • 5. Re: Alphabetical stamps
                DV22 Level 1

                While I can't view the videos mentioned, hopefully this will get you a little closer...

                 

                var pages = this.numPages;
                var stampIt = ""
                for (var i=1; i<=pages;i++) {
                var letterLen = Math.ceil(i/26);
                for (var j=0;j<letterLen;j++) {
                  stampIt += String.fromCharCode( (i+64) - ((letterLen-1)*26) );
                }

                // do the add stamp stuff here with var stampIt as the "A" "AA" part
                }

                // for testing purposes
                app.alert(stampIt);
                }

                just to go over real quickly what it is doing:

                cycles through each page

                in each page, we take the current page and divide it by 26 (how many letters in the alphabet)

                and we round it UP (thats the Math.ceil)

                Then, we cycle for however many letters we need

                and we add to the variable the A/B/C part

                to break that down:

                in javascript String.fromCharCode(int) will return a string based on the ASCII decimal character code (http://www.asciitable.com/)

                And the capital "A" starts at 65 (and our counter starts at 1) so we add 64 to the counter.

                Then, if our page count goes beyond Z (Dec 90), we want to subtract however many we are over times 26

                So if we at the "add" second letter, or third, or fourth (from the dividing page by 26 variable), we know we are that many times over 26.

                The -1 is since we dont want to do at that for our first set (where we want 1 letter, we dont subtract).

                • 6. Re: Alphabetical stamps
                  Synergy_M Level 1

                  Thanks for your help! I am having a bit of trouble with the code (I am a Javascript beginner!)

                   

                  This is what I have so far:

                   

                  var pages = this.numPages;
                  var stampIt = ""
                  for (var i=1; i<=pages;i++) {

                      var letterLen = Math.ceil(i/26);
                      for (var j=0;j<letterLen;j++) {
                        stampIt += String.fromCharCode( (i+64) - ((letterLen-1)*26) );
                      }

                   

                  if(event.source.forReal && (event.source.stampName == "#hjSF1cMSoCyoELgOvhPiPB"))
                  {
                    event.value = stampIt;
                  }


                  // do the add stamp stuff here with var stampIt as the "A" "AA" part


                  // for testing purposes
                  app.alert(stampIt);
                  }

                   

                   

                  The app.alert returns A then AB, so I know somthing isn't right! Any ideas?

                   

                  Thanks again!

                  • 7. Re: Alphabetical stamps
                    DimitriM Level 3

                    Hi Luke,

                     

                    Thanks for taking a look at the video.  We (WindJack Solutions, my company) get asked all the time about custom dynamic stamps and whether or not this or that can be done with them.  We developed that video showing what you can do with custom stamps in a PDF workflow more for educational and informational purposes.

                     

                    At this time the actual stamp scripts shown in the video are not published at www.pdfscripting.com but will be in the next few weeks, and Yes in order to download and use them you would need to be a Premium Member.

                     

                    Customizing the stamp files would not be difficult- you would need to copy the fields and associated scripts over to your PDF with the new design, or you could do a page replacement on the actual stamp file to keep from doing any script changes (which is probably the better/easier) option.  The custom toolbar button shown in the video will be included in the stamp file when we get them published to www.pdfscripting.com

                     

                    Hope this helps,

                     

                    Dimitri

                    WindJack Solutions

                    www.windjack.com

                    www.pdfscirpting.com