11 Replies Latest reply on Feb 2, 2010 10:45 AM by Appligent

    Link to an external .js from PDF?

    WereMike

      Using Acrobat 9 Pro, I have a PDF document that I want to link to an external .js file (for SCORM and LMS purposes).  I have imported a multimedia object (swf) into the PDF and it needs to call several Javascript functions.  Instead of copy/pasting each function of Javascript code into each PDF (menu path: Advanced > Document Processing > Document Javascripts), is it possible to write a line of code that links to an external .js file?

       

      In HTML, it would be someting like <HEAD><SCRIPT type="text/javascript" language="Javascript" SRC="pdf.js"></SCRIPT> </HEAD>.

       

      Possible?

        • 1. Re: Link to an external .js from PDF?
          try67 MVP & Adobe Community Professional

          I think you will have to set up the JS file as a folder-level script. Then

          you'll be able to call the functions in it from any PDF opened no your

          machine.

          • 2. Re: Link to an external .js from PDF?
            WereMike Level 1

            I thought that was what I was doing.  I will have a JS file residing in the same folder as the PDFs.  I need the SWF embedded in the PDF to call functions in that JS file.  Don't I need to add a javascript link to the PDF in order to make that connection?

            • 3. Re: Link to an external .js from PDF?
              try67 MVP & Adobe Community Professional

              That's not what a folder-level script means. It means a script that is

              located in a special folder so that it is launched when Acrobat/Reader is

              launched, before any file is opened.

              If you place a function in such a script then any PDF you open will have

              access to this function.

              You can read more about it in the Acrobat JavaScript reference files.

              • 4. Re: Link to an external .js from PDF?
                WereMike Level 1

                Try67, thanks.  You answered my question precisely.

                 

                Of course, I now realize that I asked the wrong question.  Since the PDFs will be accessed via an LMS on a server, I cannot (at least, I don't think I can...need to verify...) use a folder-level script.  I'm pretty sure I need a document-level script.  Now, if that means I have to copy/paste all the functions I need into a document-level script, it would work, but I suspect that becomes a maintenance nightmare down the road if I ever have to update/replace code on each PDF.

                 

                It would be much easier to have a document-level "link" to an external .js file, but I suspect that is impossible based on what I've read in the Acrobat Javascript reference.  Am I wrong?

                • 5. Re: Link to an external .js from PDF?
                  try67 MVP & Adobe Community Professional

                  As far as I know, it's impossible, but maybe I'm wrong on this...

                  But why should it be impossible for you to use folder-level scripts? You

                  just need to place the files at the proper location on the machine(s) where

                  Acroabt is running. Updating them should not be different than updating any

                  more software/file over a network, maybe even easier since it doesn't

                  requires any actual installation, just to copy a file somewhere on the local

                  drive.

                  • 6. Re: Link to an external .js from PDF?
                    WereMike Level 1

                    I agree with you.  But the server which runs our LMS does not have Acrobat installed on it.  And I don't see anywhere in the documentation that I can (re)define a folder-level script's path.  And, pushing out a JS file to every User's Javascripts folder is not an option due to logistics and/or security constraints.

                     

                    Unless I misunderstand what you are suggesting.  Can you perhaps offer a syntax sample to clarify?

                    • 7. Re: Link to an external .js from PDF?
                      try67 MVP & Adobe Community Professional

                      I'm not sure I understand how you're using Acrobat. Is it installed on each

                      machine, or on a server? (if the latter, you should be aware that Acrobat is

                      not a server application, and I'm not sure using it that way is allowed by

                      the EULA)

                      • 8. Re: Link to an external .js from PDF?
                        WereMike Level 1

                        I use Flash to create a SWF.  I use Acrobat to generate a PDF and embed the SWF.  The PDF will be a training piece.  All of our training must be deployed through an LMS.  The LMS connects to a server that holds all content (docs, swfs, pdfs, html, etc).  The PDF must reside on the server AND communicate with the LMS for SCORM purposes.  We have a dozen or so Javascript functions that each training piece must call to interact with the LMS.  (Unstarted, Incomplete, Complete, Score, Bookmark, etc.).

                         

                        So no, Acrobat is not installed on a server.  My target audience should all have the latest version of the Adobe Reader.  I (as a designer/developer) am using Acrobat to create a media-enhanced PDF for training purposes.

                        • 9. Re: Link to an external .js from PDF?
                          try67 MVP & Adobe Community Professional

                          I don't know these technologies, so I'm not sure about that, but it seems to

                          me that you will be able to do it if you installed the folder-level script

                          on the local machines with Reader. If that's not possible, I'm not sure I

                          have other suggestions.

                          • 10. Re: Link to an external .js from PDF?
                            WereMike Level 1

                            You have been very helpful and I appreciate it.  Your original answer is correct: the folder-level script is the way to go.  Unfortunately, I have 300K+ end-users and the process to get a JS file installed is prohibitive, which is why I was hoping to attach it at the document-level.

                             

                            I can still copy & paste all that code into the PDF at the document-level, it just becomes a maintenance headache and another step in the development process.

                             

                            Thanks for all your time and help.  It is greatly appreciated.

                            • 11. Re: Link to an external .js from PDF?
                              Appligent Level 1

                              If you do end up having to load all your scripts at the document level, it can be done in batch using an Adobe Acrobat batch sequence and

                               

                              this.addScript()