6 Replies Latest reply on May 14, 2009 1:37 AM by dhishok

    Need help to modify the Javascript...

    dhishok

      Hi everyone,

       

      We have the batch script to create PS files in InDesignCS2. We got this script from adobe forums only. And its working fine. Now i am trying to create batch script to create PDF files. Almost i have modified the script, but in the exporting stage the script shows some error in it. I have tried but unable to solve the problem. I have attached the snap shot, and find the script below.

       

       

      //--------------------------------
      #target indesign4-0
      var myFolder = Folder.selectDialog ("Please Select the Data in Input InDesign Files");
      var myFileIn = File(myFolder).getFiles("*.indd");
      var myFileOut = Folder.selectDialog("Please select the Out Put PDF Folder");
      var params = new Array();
      params = getData( myFolder, myFileIn );
      app.dialogs.everyItem().destroy();
      Opens();

       

      function getData(PDF)
      {
      var pdfPresets = app.pdfExportPresets.everyItem().name;
      var dlg = app.dialogs.add( { name : 'Choose Style' } );
      with(dlg)
      {
      with( dialogColumns.add() )
      {
      with( borderPanels.add( ) )
      {
      staticTexts.add( { staticLabel : 'PDF Presets:', minWidth : 93 } );
      dropDown = dropdowns.add( { stringList : pdfPresets, selectedIndex : 0 });
      }
      }
                 }
      if( dlg.show() == false ){
      dlg.destroy();
      exit(0);
      }
      return dropDown.selectedIndex;
      }

       

      function Opens()
      {
      for(var i=0; i<myFileIn.length; i++) {
          var myDoc =app.open(myFileIn[i], true);
          var Final = new Array();
          var myFileInPath = myDoc.filePath;
          var PDFs = new Folder(myFileOut);
          pdfUsing (params, PDFs, '.pdf');
          myDoc.close(SaveOptions.NO);
          }
      }

       

      function pdfUsing(presetName, folderPath, fileExt)
      {
         var targFolder = new Folder(folderPath);
          try{
      app.pdfExportPresets.item(presetName).pdfExportFile = new File(targFolder.fsName + "/" + app.activeDocument.name.split(".indd")[0] + fileExt);
      app.activeDocument.pdfExport(ExportFormat.pdfType, false, app.pdfExportPresets.item(presetName));
      }catch(e){
      alert('Error in pdfUsing: ' + e)
        }
      }

      alert ("Finished");

      //--------------------------------

       

       

      Please look into this and help for me. Thanks in advance

       

      Thiyagu