ZQ520 Cancel Print

S Stephen Brennan 3 years ago
97 1 0

I am developing an Android app which prints to a ZQ520 printer using CPCL and ZSDK.  A problem has been reported where extra copies of labels are printing, and I think it happens when the user has tried to print but the printer is switched off and then resubmits the print request once the printer is powered up.  Is there a way to cancel the failed request so that it does not print when the app eventually connects to the printer?  Here is my print method:
 
private boolean zebraPrint(String content) {
   boolean retval = false;
   try {
   //PrinterStatus printerStatus = printer.getCurrentStatus();   ZebraPrinterLinkOs linkOsPrinter = ZebraPrinterFactory.createLinkOsPrinter(printer);
  PrinterStatus printerStatus = (linkOsPrinter != null) ? linkOsPrinter.getCurrentStatus() : printer.getCurrentStatus();
 
   if (printerStatus.isReadyToPrint) {
   printStatus = BluetoothPrinterHelper.READY_TO_PRINT;
  System.out.println("Ready To Print");
  } else if (printerStatus.isPaused) {
   printStatus = BluetoothPrinterHelper.PAUSED;
  System.out.println("Cannot Print because the printer is paused.");
   return false;
  } else if (printerStatus.isHeadOpen) {
   printStatus = BluetoothPrinterHelper.HEAD_OPEN;
  System.out.println("Cannot Print because the printer head is open.");
   return false;
  } else if (printerStatus.isPaperOut) {
   printStatus = BluetoothPrinterHelper.OUT_OF_PAPER;
  System.out.println("Cannot Print because the paper is out.");
   return false;
  } else {
   printStatus = BluetoothPrinterHelper.UNKNOWN;
  System.out.println("Cannot Print.");
   return false;
  }
 
   byte[] configLabel = content.getBytes("ISO-8859-1");
   printerConnection.write(configLabel);
  retval = true;
  } catch (UnsupportedEncodingException e) {
   printStatus = BluetoothPrinterHelper.UNKNOWN;
  disconnect();
  e.printStackTrace();
  } catch (ConnectionException e) {
   printStatus = BluetoothPrinterHelper.DISCONNECTED;
  disconnect();
 
   if (initialise())
   return zebraPrint(content);
  }
 
 
   return retval;
}

Please register or login to post a reply

1 Replies

S Stephen Brennan

Sorry, I realised it was a bug in our app that was duplicating the output.

CONTACT
Can’t find what you’re looking for?