2 Replies Latest reply on May 27, 2010 9:14 AM by gmh77

    Prompt for export location

    gmh77

      Hello,

       

      I am creating a simple script to automate exporting a document as a pdf. How can I prompt the user for the export location with a file browser dialog? (Using javascript). Here is the script:

       

      ----

       

      // choose PDF preset
      var myPDFExportPreset = app.pdfExportPresets.item("PRESS");


      // get document name
      var myDocName = app.activeDocument.name;


      // remove .indd from filename
      var newDocName = myDocName.substring(0,myDocName.length-5);


      // create exported filename
      var myFile = File("/c/"+newDocName+" - PRESS.pdf");


      // export the PDF
      app.activeDocument.exportFile(ExportFormat.pdfType, myFile,false, myPDFExportPreset);

       

      ----

       

      Right now it exports the PDF to /c/ - but I'd like to be able to browse for the export location. Can this be done?

        • 1. Re: Prompt for export location
          Shonkyin Level 3

          You can select a folder with Folder.selectDialog()

           

          Try with below code:

           

          // choose PDF preset
          var myPDFExportPreset = app.pdfExportPresets.item("PRESS");
          
          // get document name
          var myDocName = app.activeDocument.name;
          
          // remove .indd from filename
          var newDocName = myDocName.substring(0,myDocName.length-5);
          
          //select output folder
          var myOutputFolder = Folder.selectDialog( 'Select output folder');
          
          // create exported filename
          var myFile = File(myOutputFolder + "/" + newDocName + " - PRESS.pdf");
          
          // export the PDF
          app.activeDocument.exportFile(ExportFormat.pdfType, myFile,false, myPDFExportPreset);
          

           

           

          Shonky

          • 2. Re: Prompt for export location
            gmh77 Level 1

            Perfect! Thank you very much.