3 Replies Latest reply on Aug 5, 2016 12:44 AM by Peter Kahrel

    'Cancel' Export Option should stop

    BEGINNER_X Level 3

      Hi All,

       

      I have small clarifications, but not work out...

       

       app.activeDocument.exportFile(ExportFormat.JPG, File("~/Desktop/abc.jpg"), true);
      
      

       

      Export_Jpeg.png

       

      If I click Cancel, then the Script should stop.

       

      If I click Export, then the Script move to next task in the same script.

       

      Thanks

      Siraj

        • 1. Re: 'Cancel' Export Option should stop
          karthiks94217840 Level 2

          Hi G,

           

          Try this below code;

           

          app.activeDocument.exportFile(ExportFormat.JPG, File("~/Desktop/abc.jpg"), false); 

           

          One more thing;

           

          What your need to export jpg?

           

          1. Export to JPG - all pages

          2. Export to JPG - page range

          3. Export to JPG - selection

           

          Thanks

          KS

           

           

           

          • 2. Re: 'Cancel' Export Option should stop
            BEGINNER_X Level 3

            Hi All,

             

            Trying code is below:

            Please read comments,

             

            var myDoc = app.activeDocument;
            var myJpeg_name = app.activeDocument.name.replace(/\.indd/i, ".jpg")
            var myFolder=Folder.selectDialog("Choose JPG Save Location");
            
            if(myFolder != null)
            {
              var myFile = File(myFolder + "/" + myJpeg_name);
              var myCheck = app.activeDocument.exportFile(ExportFormat.JPG, myFile, true);
              
              //-----------------Here is facing problem------------------
              if(myCheck != null)   //If customer click Export, then export
              {
                  //Proceed
                  }
              else    //If customer click cancel, then the 'Process Completed" not shown
              {
                  exit(0)
                  }
                //-----------------Here is facing problem------------------
              }
            else
            {
                exit(0)
                }
                  alert("Proceed")
                  
            var myRes = app.jpegExportPreferences.exportResolution;
            alert(myRes)
            
            var myColor = app.jpegExportPreferences.jpegColorSpace;
            alert(myColor)
            
            
            alert("Process Completed")
            
            • 3. Re: 'Cancel' Export Option should stop
              Peter Kahrel Adobe Community Professional & MVP

              Use undefined, not null:

               

              if (myCheck === undefined) {

                 // Cancel clicked, exit

                 exit()

              }

               

              You can figure out a return value just by executing the single command. So if you run this in the ESTK:

               

              app.activeDocument.exportFile(ExportFormat.JPG, myFile, true);

               

              and click Cancel in the dialog window, the ESTK prints undefined, not null.

               

              Peter

              1 person found this helpful