5 Replies Latest reply on May 14, 2009 11:20 AM by kentgbaker

    Mirror PDF page order

    kentgbaker

      I currently have a script that I repurposed to create a copy of each page of a PDF. I believe it was free from evermap. It creates a copy of each page in the PDF and orders them 1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8. Slick.

       

      app.addMenuItem({
               cExec: "duplicate_pages();",
               cParent: "Edit",
               cName: "Duplicate Pages"
      });

      function duplicate_pages() {

      var nNumCopies = 1; // make 1 additional copy(es) of each page

      try {

      var newName = this.path;
      var filename = newName.replace(".pdf","_copiedpages.pdf"); // save a copy of original document
      this.saveAs(filename);

      var Num = this.numPages;
      var nNumDups = nNumCopies+1;

      for (var i = 0; i < Num; i++) {
          for (var j = 0; j < nNumCopies; j++) {
              k = i*nNumDups + j;
              this.insertPages({ nPage: k, cPath:newName, nStart:i });
              }
          }
      }
      catch(e)
      {
          app.alert(e);
      }
      }

       

       

      What I need is to create the copied pages in a different order. No matter the number of pages....

       

      Example, an 8 page PDF is 1,2,3,4,5,6,7,8 and I want the result to be 1,2,3,4,5,6,7,8,8,7,6,5,4,3,2,1,

       

      Anyone got the 411?

       

      Thanks as always