1 Reply Latest reply on Mar 30, 2015 3:53 PM by gkaiseril

    Duplicate range of pages several times

    alex100original

      Hi!

       

      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.

      Now I'm trying to adapt the code to get what I want.

      I need a new file in which the page with the third to the last duplicated a number of times.

      The number of times to duplicate the given parameter "nNumCopies"

      Number of pages in the input file is always different so the multiplier is variable.

      Now it's copies all pages.

      Examle. an 6 page pdf 1,2,3,4,5,6 and I want in result 1,2,3,4,5,6,3,4,5,6 and ect . Pages from 3 to last duplicate several times depending on the parameter "nNumCopies"

      I think i must change nPage and nStart parameter and maybe addon parameter nEnd.

      But it is not clear how to do it correctly.

      Please help)

       

      var pageNumber = this.numPages

      var workNumber = (pageNumber - 2);

      var delNumber = (100 / workNumber);

      var delNumber = delNumber - (delNumber%1) + 1;

      var nNumCopies = delNumber;

       

      try {

       

      var newName = this.path;

      var filename = newName.replace(".pdf","_Original.pdf");

      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);

      }