5 Replies Latest reply on Sep 6, 2013 9:00 AM by Test Screen Name

    Determine the coordinates of a bookmark.

    MaxCO2012 Level 1

      Greetings:

       

      My project is rooted in Excel VBA (with some embedded javascript) and makes use of MS Word (for the document templates) and Acrobat Pro X to produce a collection of PDFs, of which some contain digital signature fields added by the VBA-embedded js.

       

      The PDFs are created in a manner that retains the Word bookmarks. Everything works well so far but, some of these Word files that get converted to PDFs are dynamic in their length and the digital signature field location needs to be dynamic as well.

       

      What I believe will work is setting a bookmark in the Word file where I want the digital signature, then "locate" that bookmark in the PDF and use the location information of that bookmark to set the coordinates of the digital signature field.

       

      Can someone please tell me how to determine the location information of a bookmark in a PDF? I can "see" them manually, but can't find anything on how to access them programmatically.

       

      Thank you.

        • 1. Re: Determine the coordinates of a bookmark.
          Dave Merchant MVP & Adobe Community Professional

          You cannot directly access the destination property of a bookmark or link using the JavaScript API.

           

          The only way to find out where a bookmark goes is to execute it.

          1 person found this helpful
          • 2. Re: Determine the coordinates of a bookmark.
            MaxCO2012 Level 1

            Thanks for the clarification.

             

            Surely, I can't be the first person needing a method to insert a digital signature field in a dynamic location.

             

            Any suggestions?

            • 3. Re: Determine the coordinates of a bookmark.
              Dave Merchant MVP & Adobe Community Professional

              You're the first on here!

               

              Acrobat is not designed to be used as a fully-automated tool, so a lot of the things that would make that possible are missing. There are also some parts of the JavaScript API that never got due attention, the bookmark and link objects being prime examples. It may change going forward, can't possibly say.

               

              You can find the coordinates of words on a page with JS, and you can cycle through every word on every page to 'search' for something. So in theory if you block out the signature's position using a unique sequence of characters (filled with white so they don't appear on screen) you could use them to map in your signature field.

               

              Look at example 2 for doc.addLink() in the Acrobat JavaScript API documentation ( http://bit.ly/AXISDKH ). It does pretty much the same thing, but you'd be adding a form widget (with doc.addField) instead of a link object.

              1 person found this helpful
              • 4. Re: Determine the coordinates of a bookmark.
                MaxCO2012 Level 1

                Excellent suggestion. I'll give that a try and see how the speed goes finding that "white" word.

                 

                I was also working towards determing the location of the bookmark in the Word template data and making the coordinates calculation from there, but bookmark coordinates are proving elusive also.

                 

                And yet another idea, similar to your suggestion, is to place an invisible rectangle in the Word template and use those coordinates.

                 

                Thanks again.

                • 5. Re: Determine the coordinates of a bookmark.
                  Test Screen Name Most Valuable Participant

                  Part of the issue is the complexity of bookmarks, which would need a huge object model in JavaScript to represent it. Bookmarks, links and form fields can have one or more actions associated with them. The set of actions is open ended but include at least 15 different types, many with complex sub-dependencies. Only three of these types could be said to have a coordinate, but you should be aware that in no case is the coordinate usually a small area. Generally it's an entire page or chunk of page. What is preserved precisely is the source of a link area, but there is no method to get that either.