1 Reply Latest reply on Sep 30, 2014 4:49 AM by try67

    Cancel printing depending on value

    bruce00j

      Hi,

       

      I have print buttons on a  PDF form I am making.

      I have 4 buttons 1 for printing the whole document to different printers (for different size labels ect.) and 3 buttons to print off each page individually.

       

      2 of the print buttons lets the user define an amount in a dialogue box but if the user presses cancel it still prints but with a value of 1 even if I define the value as 0 and cancel.

       

      here is the code I use for it.

       

      var resp = +app.response("How many sleeve labels do you want to print?","","0");
      var pp = this.getPrintParams();
      if (!isNaN(resp)) {  
          var pp = this.getPrintParams();  
          pp.NumCopies = resp;  
          pp.printerName = "printer name here";
          pp.firstPage = 1;
          pp.lastPage = 1;
          pp.interactive = pp.constants.interactionLevel.automatic
          this.print(pp);  
      }
      

       

      Is there a bit of code I'm missing? I am not sure what to put if there is.

       

      Thanks,

      Bruce

        • 1. Re: Cancel printing depending on value
          try67 MVP & Adobe Community Professional

          The null value that is returned when by the response method when you cancelled is converted to zero by the plus symbol.

          You should use something like this:

           

              var resp = app.response("How many sleeve labels do you want to print?","","0");  
              if (resp!=null && resp!="" && !isNaN(+resp)) {
                  var pp = this.getPrintParams();    
                  pp.NumCopies = +resp; 
                  pp.printerName = "printer name here";  
                  pp.firstPage = 1;  
                  pp.lastPage = 1;  
                  pp.interactive = pp.constants.interactionLevel.automatic  
                  this.print(pp);    
              }