How to print multiple labels from android app.

N Nikhil Virupakshi 3 years 6 months ago
105 1 0

Hello,
 
We are building an android app where we have to print multiple labels.
But currently, we are able to print a single label so what method needs to be used to print multiple labels.
Also, we need a call back on print success and failure so that we can display the number of successful print and failure.
and also is there any cancel or stop method for canceling ongoing printing.
 
 
Any help would be appreciated.
 
 
Thanks..

Please Register or Login to post a reply

1 Replies

Y Yanis Dalabiras

Hi Nikhil,
If you are printing multiple labels at one time, you have a few options.  If you are primarily trying to serialize data with your multiple labels, there is a ZPL command (^SN) to help.  If your label data is fairly small and you only need to print a few at a time, you can combine them in the same data stream or not worry too much about print success or failure.  The printer will buffer the print jobs.
On the other hand, if you are printing a lot and you need to keep track of how many printed or have a large label with images, you can do a few things to keep track of your print jobs while printing.  This only really works with ZPL and some of the virtual devices, so hopefully that is what you're using.
We recommend using the StatusConnection for this method, especially as it won't interfere with printing.
The code below shows how to do it. You can also use the status "numberOfFormatsInReceiveBuffer" to send multiple labels and still keep track of them.
        // Check during / after printing        private boolean postPrintCheckPrinterStatus(Connection connection)        {            ZebraPrinter printer = ZebraPrinterFactory.getInstance(PrinterLanguage.ZPL, connection);            PrinterStatus printerStatus = printer.getCurrentStatus();                        // loop while printing until print is complete or there is an error            while ((printerStatus.numberOfFormatsInReceiveBuffer > 0) && (printerStatus.isReadyToPrint))            {                printerStatus = printer.getCurrentStatus();            }            if (printerStatus.isReadyToPrint) {                 System.out.println("Ready To Print");                 return true;             } else if (printerStatus.isPaused) {                 System.out.println("Cannot Print because the printer is paused.");             } else if (printerStatus.isHeadOpen) {                 System.out.println("Cannot Print because the printer head is open.");             } else if (printerStatus.isPaperOut) {                 System.out.println("Cannot Print because the paper is out.");             } else {                 System.out.println("Cannot Print.");             }            return false;        }
Hope this helps,
Robin

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