ZQ520 - Image print problem (Zebra Android SDK)

// Expert user has replied.
A Anastassia Rakitianskaia 2 years 11 months ago
328 1 0

We used to use the Zebra RW420 model, together with the GraphicsUtil interface functionality from the Zebra Android SDK, which allowed us to use the printImage() method and send an image to the printer on the fly, together with the rest of the receipt data in CPCL language. The image printing looked like this:
 
com.zebra.sdk.printer.ZebraPrinter printer = ZebraPrinterFactory.getInstance(connection);    System.out.println("x: " + x + " y: " + y + " width: " + width + " height: " + height);   connection.write("! U1 JOURNAL\r\n! U1 SETFF 20 2\r\n".getBytes());    printer.printImage(new ZebraImageAndroid(bitmap), x, y, width, height, false); 
However, since we switched to Zebra ZQ520 model, the same functionality does not work, and instead of printing an image, the printer prints out a lot of hexadecimal characters. This thread is a duplicate of another thread on this discussion board (https://developer.zebra.com/thread/30659), and on that thread an answer was posted stating that the printer should be manually set to use the ZPL language, and the same code should be tested once again. No more feedback was posted after that.
 
Following the advice above, our code to print an image was changed to:
 
public boolean printImage(final Bitmap bitmap, final String fileName, int x, int y, int width, int height, PrinterLanguage language,    PrintListener listener) { //in this case PrinterLanguage.ZPL was passed into the method   if (connection != null) {   if (connection.isConnected()) {   try {        com.zebra.sdk.printer.ZebraPrinter printer = ZebraPrinterFactory.getInstance(language, connection);  //used to be ZebraPrinterFactory.getInstance(connection) for RW420        printer.printImage(new ZebraImageAndroid(bitmap), x, y, width, height, false);        listener.onPrintSuccess();        return true;    } catch (ConnectionException e) {        listener.onPrintFail();        e.printStackTrace();        try {             connection.close();        } catch (ConnectionException e1) {        e1.printStackTrace();        }   }  finally {        if (bitmap != null && !bitmap.isRecycled()) {        bitmap.recycle();        System.gc();        }   }           } else {   listener.onPrintFail();           }   }   return false; } 
However, that still did not change the result and the image was printed as hex values. We also tried another approach where the image was stored on the printer first via the following code:
 
com.zebra.sdk.printer.ZebraPrinter printer = ZebraPrinterFactory.getInstance(language, connection); ZebraImageI zebraImage = ZebraImageFactory.getImage(bitmap);  printer.storeImage("E:" + fileName.toUpperCase(), zebraImage, width, height); 
Unfortunately, the method to store the image on the printer did not change the result - whenever we tried to print the stored image, the same issue happened and a lot of hexadecimal characters were printed out.
 
 
We attempted a third approach, using the ZebraUtilities application. An image was successfully loaded onto the printer via the ZebraUtilities, and afterwards the following code was run to print the image:
 
com.zebra.sdk.printer.ZebraPrinter printer = ZebraPrinterFactory.getInstance(language, connection); printer.getConnection().write(("^XA^FT" + x + "," + y + "^XGSIMPLE-BLACK-CAR-HI.GRF,1,1^FS^XZ").getBytes()); 
That only printed the command itself as a string.  We also attempted to use the sendCommand(String) method from the ZebraPrinter class of the Zebra Android SDK, but that returned the same results – printing the command as is on paper.
 
We also used ZebraUtilities to manually set the language to ZPL on Zebra ZQ520, by sending -- ! U1 setvar "device.languages" "ZPL" – command to the printer via the “Open Communication With Printer” tool from the ZebraUtilities application. Unfortunately, that did not change the way the printer interpreted the ZPL command for image printing, as the command kept getting printed as a String. It also did not change the situation when we tried the printImage() method from the GraphicsUtil interface of the Zebra Android SDK.
 
We also tried to use the ZebraUtilities Android app from Google Play Store, and the image print via the app renders the same results.
 
It looks like the printer does not interpret ZPL language for some reason.
 
Could anyone advise as to what could be done in this case? What is missing in the code above, or what should be changed in the steps that are taken before the image can be printed? Firmware version of our ZQ520 is V76.19.13Z.

Please register or login to post a reply

1 Replies

M Manuel Caicedo-Rivera

Hi Anastassia,

The behavior, you described, happens when the printer language is "line_print".

When you tried to set up the language to ZPL, it was not accepted by the printer because the command is case sensitive. In other words, you can try the command like this

! U1 setvar "device.languages" "zpl"

ZPL must be in lower case in order to be accepted by the printer.
The printer ZQ510 by default is set up in "line_print".

For more information about Zebra's API, please follow the link below
Zebra API for Android (build v2.9.2275)
For more information about our recommendations to develop apps with Zebra printers, please, follow the link below
Zebra Technologies - Best Practices in Creating a Printing Application for Zebra Printers

Please, let us know if you were able to set up the language to ZPL. Otherwise, please, reach us at ISV_NALA_Support@zebra.com

Thanks,

MC

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