3 Replies Latest reply on Aug 24, 2008 6:30 PM by gkaiseril

    Need Help Running a JavaScript in Acrobat Pro 4

      How does one run a JavaScript in Acrobat Pro 4? I know it is an old version, but does someone still know?
        • 1. Re: Need Help Running a JavaScript in Acrobat Pro 4
          gkaiseril MVP & Adobe Community Professional
          There is no Professional version for 4 or 5. JavaScript in version 4 can run in the same context as the newer versions except for the use of the JavaScirpt console to execute JavaScripts. That is, you can can page actions, bookmark actions. field actions, and document actions. For the document actions one needs to look under the "Tools" option on the menu bar. If you want to execute some JavaScirpt one can add a button field to a PDF or a bookmark with a JavaScript action.
          • 2. Re: Need Help Running a JavaScript in Acrobat Pro 4
            Level 1
            Ok, I have figured out how to run a JavaScript file. What is wrong with the following code - are these commands not supported in Acrobat 4?



            app.addMenuItem({ cName: "Collate Document", cParent: "Tools", nPos: 0, cExec: "collate()"});

            /*
            Title: Collate Document
            Purpose: User is prompted to select document to insert/collate.
            Author: Sean Stewart, ARTS PDF, www.artspdf.com
            */

            function collate()
            {

            this.insertPages (0,"scan0002.pdf", 0);

            // create an array to use as the rect parameter in the browse for field

            var arRect = new Array();
            arRect[0] = 0;
            arRect[1] = 0;
            arRect[2] = 0;
            arRect[3] = 0;

            // create a non-visible form field to use as a browse for field

            var f = this.addField("txtFilename", "text", this.numPages - 1, arRect);

            f.delay = true;
            f.fileSelect = true;
            f.delay = false;

            // user prompted to select file to collate the open document with

            app.alert("Select the PDF file to merge with; this should be the odd-numbered pages:")

            // open the browse for dialog

            f.browseForFileToSubmit();
            var oddDocPath = f.value;

            var halfOfPages = this.numPages;

            // insert pages from selected document into open document

            for (var i = 0;i < halfOfPages; i++) {
            this.insertPages(halfOfPages-i, evenDocPath, i);
            }

            // remove unused field

            this.removeField("txtFilename");

            }

            • 3. Re: Need Help Running a JavaScript in Acrobat Pro 4
              gkaiseril MVP & Adobe Community Professional
              Have you opened the JavaScript console and found any messages?

              What is the message you have in the JavaScript console.

              I said you could not run a JavaScript from the console. One can still see error messages and write to it to aid in Debugging scripts.

              1. One can not use the parameter name in a built-in JS function call before version 5 or 6.

              2. The "addMenuItem" method is not available below version 5.

              3. The "insertPages()" method is not available below version 5.

              4. The "removeField()" method is not available below version 5.

              It is pretty obvious one will need version 5 or above to use this script.

              If you download a copy of the JavaScript API for any version of Acrobat and look at the property's or method's quick box you can determine the version required to use that particular property or method by the number in the first box of the quick bar.