3 Replies Latest reply on Feb 10, 2018 8:55 AM by Sachinji

    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.

            • 3. Re: Import multiple pdf into indesign file
              Sachinji Level 1

              Hi Bala,

               

              Please help!

              open test.indt file and import pdf alone with there trim size after that close with crop size placed pdf file naming.

               

              Example:

              • a.pdf 1 page trim 4X6" crop 4.5X6.425"
              • b.pdf 2 pages trim 5X7.234" crop 5.427X7.528"

               

              I have folder with different size 1, 2 or 3 page pdfs. I need to place in .indt file with respective pdf trim size with cropped size placed.

              I am getting error message in indesign CC15 and CC18.

               

              Thanks

              Sachin