7 Replies Latest reply on Jul 30, 2014 4:47 AM by Dapeamel

    batch pdf export script problem

    Dapeamel Level 1

      Hello guys,

       

      I got problem with my code cause it doesn't work at all,

       

      Could someone help me to correct it

      it's something with the exportfile line13

       

      
      //==== Batch PDF =====\\
      /* InDesign JavaScript to Create PDFs of a batch of InDesign files using an export PDF preset */
      var myPDFExportPreset = app.pdfExportPresets.item("Smallest file size"); // Change myPDFpreset to the name of the preset you want to use
      var myFileLocation = Folder.selectDialog("Please select path to files");
      myFolder = new Folder ([myFileLocation]);
      myFolderContents = myFolder.getFiles("*.indd"); // array
      myFileAmount = (myFolderContents.length - 1);
      // ===== Open, Export as PDF, and Close files ===== \\ 
      for (i = myFileAmount; i >= 0; i--)
      { 
      app.open(File (myFolderContents[i]));
      app.activeDocument.exportFile(
        ExportFormat.pdfType, 
        File(myFolder.fsName + "/" + app.activeDocument.name.split(".indd")[0] + ".pdf"),
        false, 
        myPDFExportPreset
        );
      app.activeDocument.close(SaveOptions.no);
      }
      
        • 1. Re: batch pdf export script problem
          Sajeev Sridharan Level 4

          Try this, add your pdf preset name in your code like below...

           

          //==== Batch PDF =====\\ 

          /* InDesign JavaScript to Create PDFs of a batch of InDesign files using an export PDF preset */ 

          var myPDFExportPreset = app.pdfExportPresets.item("Smallest file size"); // Change myPDFpreset to the name of the preset you want to use 

          var myFileLocation = Folder.selectDialog("Please select path to files"); 

          myFolder = new Folder ([myFileLocation]); 

          myFolderContents = myFolder.getFiles("*.indd"); // array 

          myFileAmount = (myFolderContents.length - 1); 

          // ===== Open, Export as PDF, and Close files ===== \\  

          for (i = myFileAmount; i >= 0; i--) 

          {  

              var myPDFExportPreset = app.pdfExportPresets.item("your preset name");//type your preset name here

           

           

          app.open(File (myFolderContents[i])); 

          app.activeDocument.exportFile( 

            ExportFormat.pdfType,  

            File(myFolder.fsName + "/" + app.activeDocument.name.split(".indd")[0] + ".pdf", myPDFExportPreset), 

            false,  

            myPDFExportPreset 

            ); 

          app.activeDocument.close(SaveOptions.no); 

           

          Vandy

          • 2. Re: batch pdf export script problem
            Jump_Over Level 5

            Hi Vandy,

             

            Why so quick?

            • preset is declared in the 1st line already.
            • We cannot include a preset into File() declaration.

             

            I suggest to add "new" before "File" in the beginning of line 14, since target file for export wasn't created already (it was but is not valid).

            I mean:

            ...

              13. ExportFormat.pdfType, 

              14. new File(myFolder.fsName + "/" + app.activeDocument.name.split(".indd")[0] + ".pdf"),

            ....

             

            Jarek

            • 3. Re: batch pdf export script problem
              Sajeev Sridharan Level 4

              Oops.... you're right Jarek....

               

              Vandy

              • 4. Re: batch pdf export script problem
                Dapeamel Level 1

                hmm I didn't got it work actually

                could you send me a correct code snippet.

                 

                Thank you in advance Jarek,

                • 5. Re: batch pdf export script problem
                  Sajeev Sridharan Level 4

                  //==== Batch PDF =====\\ 

                  /* InDesign JavaScript to Create PDFs of a batch of InDesign files using an export PDF preset */ 

                  var myPDFExportPreset = app.pdfExportPresets.item("[Smallest File Size]"); // Change myPDFpreset to the name of the preset you want to use 

                  var myFileLocation = Folder.selectDialog("Please select path to files"); 

                  myFolder = new Folder ([myFileLocation]); 

                  myFolderContents = myFolder.getFiles("*.indd"); // array 

                  myFileAmount = (myFolderContents.length - 1); 

                  // ===== Open, Export as PDF, and Close files ===== \\  

                  for (i = myFileAmount; i >= 0; i--) 

                  {  

                  app.open(File (myFolderContents[i])); 

                  app.activeDocument.exportFile( 

                    ExportFormat.pdfType,  

                    new File(myFolder.fsName + "/" + app.activeDocument.name.split(".indd")[0] + ".pdf"), 

                    false,  

                    myPDFExportPreset 

                    ); 

                  app.activeDocument.close(SaveOptions.no); 

                   

                  Vandy

                  • 6. Re: batch pdf export script problem
                    Sajeev Sridharan Level 4

                    PDF preset name was mentioned wrongly in the code....

                     

                    Vandy

                    • 7. Re: batch pdf export script problem
                      Dapeamel Level 1

                      works like a charm!

                      awesome cheers