1 Reply Latest reply on Mar 28, 2012 12:46 PM by George_Johnson

    Organizing JavaScript Code in External .JS Files?

    insuractive Level 3

      Is it possible to reference javascript stored in an external file hosted on a remote server?  We have a number of PDF forms (which are generated by a 3rd party) that we need to add JS validation to.  These will be distributed to our public users in the field.  Rather than manually copy-paste the same JavaScript into 20 different PDFs, I'd prefer to encapsulate the logic somehow and resuse the same code.  So far my searches haven't turned up anything that would work in this situation.  There is a question on this forum dealing with the same issue that I found, however the solution seems to revolve around folder-level functions, which I don't believe I can use since my users who are consuming the PDF will be remote.  Its possible that I am misunderstanding the restrictions on folder-level functions, though from reading through the adobe documentation it seems like you need to apply to code to the directory structure of the system on which Acrobat/reader is being run.


      How are folks organizating your JavaScript code when dealing with a large document library?  Are there methods I can use to load in an external library?


      Any help would be greatly appreciated!




      - Michael

        • 1. Re: Organizing JavaScript Code in External .JS Files?
          George_Johnson MVP & Adobe Community Professional

          Your options are to include the code in the individual PDFs or in a folder-level JavaScript file that must be installed on each user's machine. What you're asking for is not possible.


          There are ways to make populating a form with document-level JavaScript easier, including an FDF and adding the pages of each form to a single page PDF that contains the JavaScripts, and then deleting the page.