3 Replies Latest reply on Feb 1, 2017 10:12 AM by saint francish32929554

    Split PDF using an Action with Java Scipt.

    saint francish32929554

      Our company needs to split mulitple pdf files.  The files must = 25 pages or less after spliting.  For example 102 page file would output 5 files.  4=25pages, and 1=2 remaining pages. I have a script but it only outputs 2 pages.

       

       

      /*Extract pages 25 at a time with leading zerors for proper sort */

      function padLeft (s,len,c){

      c=c || '0';

      while (s.length< len) s= c+s;

      return s;

      }

      // regular expression used to acquire the base name of file

      var re = /\.pdf$/i;

      //file name is the base name of the file acrobat is working on

      var filename = this.documentFileName.replace (re,"");

      try {for (var i = 0; (i*2) < this.numPages; i++)

      this.extractPages({

      nStart: i * 2,

      nEnd: (i * 2) + 1,

      cPath: filename + "-" + padLeft ((i + 1) + "",3) +".pdf"

      });

      } catch (e) { console.println("Aborted: " + e)}