2 Replies Latest reply on May 23, 2008 11:06 PM by (AndrewHall)

    Acrobat 7, Running a JS

      I have never scripted for Acrobat, though I have done a lot of JS scripting for Photoshop. I have written a script that will do a page by page merge of two pdfs (ie one being the front side scan of a document and one the reverse side scan). It works fine.

      What I would like to do is open the two pdfs, have the first document active, then run the script and away it goes, knowing that the front,ost pdf is where it gets the first page from. My problem is how do I set up the script so that it can be run from any open pdf, when I want to run it.

      ie:
      1. Open target pdfs for merging
      2. Make sure the initial page pdf is on top
      3. run script somehow (from menu, or button?)

      Andrew
        • 1. Re: Acrobat 7, Running a JS
          Level 1
          I've found a solution, using batch and requiring only 2 pdfs to be open, then creating the new merged pdf, and aborting the script when there are three pdfs open, so it only runs once:

          function runonce() {
          var d = app.activeDocs;
          var path1 = this.path;
          var doc1P = this.numPages;
          if (d.length > 2) {
          return;
          }

          for (var i=0; i < d.length; i++) {
          if (d[i].path == path1) continue;
          var path2 = d[i].path;
          }
          var newDoc = app.newDoc();
          for (var i = 0; i < doc1P; i++) {
          newDoc.insertPages({
          nPage: newDoc.numPages -1,
          cPath: path1,
          nStart: i,
          });
          if (i == 0) newDoc.deletePages({nStart: 0});
          newDoc.insertPages({
          nPage: newDoc.numPages -1,
          cPath: path2,
          nStart: i,
          });
          }
          }
          runonce()
          • 2. Re: Acrobat 7, Running a JS
            Level 1
            Wow that is ugly, you can read the code better here (with instructions)

            http://www.ps-scripts.com/bb/viewtopic.php?p=8772#8772

            Andrew Hall