9 Replies Latest reply on Dec 29, 2009 7:14 AM by gkaiseril

    PDF and Javascripting

    Tech_Krishna

      I am using Adobe Acrobat 5.0.

       

      I am having two issues.

       

      Issue 1:


      A javascript code is written such that when a hyper link is clicked
      the code will make a specific bookmark to automatically expand or
      collapse. Each time the link is clicked the book mark
      expands/collapses as expected but the child within the bookmark
      gets deleted for every click! When all the children of the bookmark
      gets deleted again the child names are listed in full. How to
      correct this.

      Code:

       

      var bmark = bookmarkRoot.children[0];

       

      //following command will expand the specific bookmark.

       

      bmark.children[0].open=true;

       

      //in the above-specified bookmark I have 4 children (topics). Each
      time the link is clicked, the bookmark expands but the children get
      deleted.

       

      Normally we can create hyperlinks in PDF through "Link Properties".
      Is it possible to create hyperlinks through javascript?

       

      When a hyperlink is clicked a specific bookmark is called to view
      its contents. This is OK when dealing with one or two bookmarks. In
      case of more than 10 bookmarks Is it possible to bring the bookmark
      (say 15th bookmark that is not in view) directly to focus through
      javascript code.

       

      Issue 2: Index

      Using Index wizard I generated the index for the PDF. But I don't understand how to call or use this index (.pdx) file in my document.

       

      Thanks in advance.

       

      With thanks and regards,

      P Krishna

        • 1. Re: PDF and Javascripting
          Bernd Alheit Adobe Community Professional & MVP

          Each time the link is clicked the book mark expands/collapses as expected but the child within the bookmark gets deleted for every click! When all the children of the bookmark gets deleted again the child names are listed in full.

          Can you post a sample document?

          • 2. Re: PDF and Javascripting
            Tech_Krishna Level 1

            Hi,

             

            Yes, I am attaching a sample PDF here.

             

            In this document,

             

            1. The hyperlink is provided for "jargon for technical writing" in the right side. The javascript code is written for this link.

            2. The "New Bookmark" has 3 children. Initially it is shown in collapsed state.
            3. Click the hyperlink to expand the "New Bookmark". In the first instance all the three child bookmarks under "New Bookmark" are shown.
            4. Now, collapse the "New Bookmark" and again click the hyperlink. Only two child bookmarks will be shown.
            Again collapse and try only one child is shown.
            5. After that you try again all the 3 children appear again and the cycle repeats.

             

            the javascript code is (sample):

             

            var bmark = bookmarkRoot.children[0];

             

            //following command will expand the specific bookmark.

             

            bmark.children[0].open=true;

             

            Please Help!!

             

            Also: Is it this possible - when a link is clicked, the page is shown but I want the bookmark also brought into the focus on the left hand side pane.

             

            thanks and regards,

            Krishna

            • 3. Re: PDF and Javascripting
              Bernd Alheit Adobe Community Professional & MVP

              I can't see any problem with Adobe Reader 8 or 9. May be a problem of the old Acrobat 5.

              • 4. Re: PDF and Javascripting
                try67 MVP & Adobe Community Professional

                In Reader the open property is read-only, so how could it have worked for you?


                • 5. Re: PDF and Javascripting
                  Bernd Alheit Adobe Community Professional & MVP

                  I tested it with Adobe Reader. Don't know why it works.

                   

                  When I look at the documentation I can see following:

                   

                  Quick bar: property is not allowed in Adobe Reader

                   

                  Access: Adobe Reader: R only

                  • 6. Re: PDF and Javascripting
                    Tech_Krishna Level 1

                    Hi,

                     

                    Thanks for the reply.

                     

                    I should have mentioned earlier that I tested the whole thing in Adobe Acrobat 5.0 with writer software. It is in the writer I am having this problem. In case of viewing it in Reader such a problem does not arise (as u said). I myself tested in Adobe Reader 7.0 and also in Adobe Reader 5.0 it is fine in it.

                     

                    I am in a dilemma that if the issue comes in PDF writer tool will there be any chance of it showing up on Adobe Reader (in any of its version)? So with this dilemma I am not able to decide on providing the scripting to the bookmarks.

                     

                    I hope I am clear. My apologies for not mentioning the exact situation earlier.

                     

                    With thanks and regards,

                    P Krishna

                    • 7. Re: PDF and Javascripting
                      gkaiseril MVP & Adobe Community Professional

                      There are a number of items that work in Acrobat and not Reader. Adobe has documented them in the Acrobat JavaScript API Reference with a feature known as the Quick Bar. This reference list what versions can use the property or method, if there is a restriction that applies only to Reader, and what and when special security restrictions were added for a given property or method.

                      • 8. Re: PDF and Javascripting
                        Tech_Krishna Level 1

                        Hi,

                         

                        Thanks for the feedback. I will check with API once again.

                         

                        So if the issue is only seen in the writer it will not appear in Reader right? That is what I wanted to know.

                         

                        Further, can you please let me know this: I have generated the index for my document. the output is ".pdx" file. How to attach it to the PDF so that the index details can be clicked by the user.

                         

                        regards,

                        Krishna

                        • 9. Re: PDF and Javascripting
                          gkaiseril MVP & Adobe Community Professional

                          Acroabt or Writer has the full JS features. Reader's JS is more restricted. So if something is available to Acrobat it might not be available to Reader. Version 5 of Reader is known to allow almost everything that Acrobat has because of an update blunder by Adobe. You should also be aware that Adolbe's documentation is sometimes wrong so beyond checking what the documentation says, testing is advisable. Also there are some JS propperties or methods that are only available to certain variations of Acrobat like 'Professional' or 'Extended'. So you really need to use the Acrobat JS API and the quick bars within the document.

                           

                          The 'PDX' file is only used on non-web based PDFs and you can use the PDF's document properties to associate a PDX or catalog file with a PDF.