2 Replies Latest reply on Sep 11, 2014 2:30 AM by ocinfr73

    Extract page with separator

    ocinfr73

      Hello

      I'm a begginner on javascript for acrobat 10

      I want to split a pdf file into multiple party. Each part is separated by a page that contains a string known predefined.

      Based on this script I have write that:



      var pageArray = [];

      var Pagedebut=0;

      var Pagefin = 0;

      // DEFINITION DU SEPARATEUR

      var ChaineSeparateurAChercher ="CCLVGSEPARATEYOURPDFHEREBYNA"

      // RECHERCHE DU SEPARATEUR

      for (var p = 0; p < this.numPages; p++) {

          // iterate over all words

          for (var n = 0; n < this.getPageNumWords(p); n++) {

              if (this.getPageNthWord(p, n) == ChaineSeparateurAChercher) {

                  pageArray.push(p);

                  break;

              }

          }

      }

      // Extraction des pages

      if (pageArray.length > 0) {

              for (var n = 0; n < pageArray.length; n++) {

                    //Création du nouveau document

              var newdoc = app.newDoc();

                      // Extraction Page vers nouveau fichier

                  newdoc.insertPages( {

                  nPage: d.numPages-1,

                  cPath: this.path,

                  nStart: Pagedebut,

                  nEnd: pageArray[n],

              } );

              // Suppression page blanche dans nouveau ficheir

              newdoc.deletePages(0);

              // Suppression page Separateur dans nouveau ficheir

              newdoc.deletePages(d.numPages-1);

              //enregistrement du fichier

              var NomNvFichier = this.documentFileName + "_Extrait-" + n

              var PathNvFichier = this.path.replace(this.documentFileName,NomNvFichier);

              newdoc.saveAs(PathNvFichier);

              // Redifinition page debut = pagefin

              var Pagedebut = pageArray[n]

          }

      }


      When i start this script I have an error  on " Doc.saveAs:43" but the debbugger (or me ) don't work fine and i don't know what is this error


      Can Anyone help me?


      Sorry for my "Google translate " English