2 Replies Latest reply on Feb 27, 2013 2:23 AM by BEGINNER_X

    Import multiple pdf into indesign file

    BEGINNER_X Level 3

      Hi ALL,

       

      Trying Script:

       

      By using inbuilt script "PlaceMultipagePDF.jsx" import all the pdf in the selected folder (i.e., 111.pdf, 222.pdf, 333.pdf) in the "test.indt"

       

       

      But my requirement:

       

      1. open test.indt file and import 111.pdf alone after that close with any file naming.

       

      2. open test.indt file and import 222.pdf after that close with any file naming.

       

      3. open test.indt file and import 333.pdf after that close with any file naming.

       

       

       

      Trying Script Code:

       

      var myFolder = Folder.selectDialog("Select the folder containing the Indesign Files", "");

      var myIFiles = myFolder.getFiles("*.indt")

       

      for(j=0; j<myIFiles.length; j++)

      {

          var myIndesignFile = myIFiles[j]

          app.open(myIndesignFile)

         

       

      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

         

      var myFolder = Folder.selectDialog("Select the folder containing the PDF Files", "");   //Please check this line

      var myFiles = myFolder.getFiles("*.pdf")

      for(i=0; i<myFiles.length-1; i++)

      {

          var myPDFFile= myFiles[i]

          var myDocument = app.documents[0];

       

              if(myDocument == true){

                  var myPage = myChoosePage(myDocument);

              }

              else{

                  myPage = myDocument.pages.item(0);

              }

              myPlacePDF(myDocument, myPage, myPDFFile);

          }

       

      }

       

       

       

       

      function myChoosePage(myDocument){

          var myPageNames = new Array;

          //Get the names of the pages in the document

          for(var myCounter = 0; myCounter < myDocument.pages.length;myCounter++){

              myPageNames.push(myDocument.pages.item(myCounter).name);

          }

          return myPage;

      }

       

       

      function myPlacePDF(myDocument, myPage, myPDFFile){

          var myPDFPage;

          app.pdfPlacePreferences.pdfCrop = PDFCrop.cropMedia;

          var myCounter = 1;

          var myBreak = false;

          while(myBreak == false){

              if(myCounter > 1){

                  myPage = myDocument.pages.add(LocationOptions.after, myPage);

              }

              app.pdfPlacePreferences.pageNumber = myCounter;

              myPDFPage = myPage.place(File(myPDFFile), [0,0])[0];         //check this line

              if(myCounter == 1){

                  var myFirstPage = myPDFPage.pdfAttributes.pageNumber;

              }

              else{

                  if(myPDFPage.pdfAttributes.pageNumber == myFirstPage){

                      myPage.remove();

                      myBreak = true;

                  }

              }

              myCounter = myCounter + 1;

          }

      }

       

       

      Can anyone give solution for my question.

       

       

      Thanks

      BEGINNER

        • 1. Re: Import multiple pdf into indesign file
          R-Bala-Krishnan Level 2

          Hi,

          Try b/m code

          var myFolder = Folder.selectDialog("Select the folder containing the Indesign Files", "");

          var myIFiles = myFolder.getFiles("*.indt")

          for(j=0; j<myIFiles.length; j++)

          {

              var myIndesignFile = myIFiles[j];

              app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

              var myFolder = Folder.selectDialog("Select the folder containing the PDF Files", "");   //Please check this line

              var myFiles = myFolder.getFiles("*.pdf")

              for(i=0; i <= myFiles.length-1; i++)

              {

                  app.open(myIndesignFile);

                  var myPDFFile= myFiles[i];

                  var myDocument = app.documents[0];       

                  if(myDocument == true){

                      var myPage = myChoosePage(myDocument);

                      }

                  else{

                      myPage = myDocument.pages.item(0);

                      }

                  myPlacePDF(myDocument, myPage, myPDFFile);

                  if(app.activeDocument.modified == true){           

                      app.activeDocument.save(new File(String(myFiles[i]).replace('.pdf','') + ".indd"));

                      app.activeDocument.save();

                      app.activeDocument.close()

                      }

                  }

              }

           

          --

          Thanks

          Bala...

          • 2. Re: Import multiple pdf into indesign file
            BEGINNER_X Level 3

            Hi Bala,

             

            Thanks a lot.....

             

             

            Its really helpful for me.