3 Replies Latest reply on Apr 6, 2014 12:38 PM by try67

    How to create a bookmark with an action "Go to a page in this document" using JavaScript?

    SwLyon

      How to create a bookmark with an action "Go to a page in this document" using JavaScript? The bookmark needs to use this form and not run a JavaScript action to go to a page.

        • 1. Re: How to create a bookmark with an action "Go to a page in this document" using JavaScript?
          try67 MVP & Adobe Community Professional

          Not possible. Using JS you can only assign "Execute JavaScript" actions.

          • 2. Re: How to create a bookmark with an action "Go to a page in this document" using JavaScript?
            SwLyon Level 1

            Thank you so much for the reply.

             

            I did find a way to make JS work.

             

            I wanted to give a little more background on the problem if others are facing it. I make a lot of PDF files and bookmark them heavily using scripts. This has not been a problem in the past because most were viewed on a full laptop or workstation. More and more they are being viewed on tablets and all of the implantations of readers for this format, that I have found, do not include a java engine. The bookmarks that you make thorough the UI work just fine. If you take a look at the results of a UI bookmark you can see that it does not use a JavaScript action. This tells me that there must be a way that the UI is assigning a go to page for a bookmark but I could not find it in the research that I had done up to that point. So the following does not work on an Android tablet:

             

            var myRoot = this.bookmarkRoot;

            myRoot.createChild('11.2.1 Adaptive Huffman Coding','this.pageNum=591;');

             

            It does create a bookmark and assigns it a page number via an action and it does show up on the tablet but it does not work.

             

            In doing some more research on the problem I found the execMenuItem method and it will create a bookmark for the page that you are on. This looks to me like it simulates the UI. So I have started to use the following in a loop:

             

            this.pageNum = 32;

            app.execMenuItem('NewBookmark');

            this.bookmarkRoot.children[9].name = '1.2: Computer Systems: Hardware and Software';

             

            Using this method you have to control both the page that you want to move to and the index of the bookmark but this is a simple task. Both versions move through the document in about the same time.