ZQ521 printer does not print .pcx cpcl image using storeImage - Android


Hello, I'm having an image printing problem on the zq521 printer, I work in an application that prints water bills, and a customer requested to print an image from a hydrometer, on RW420 printers I can print these images normally, here is my code:

private void printPhotoFromExternal(ZebraPrinter zebraPrinter, final Bitmap bitmap) throws IOException, ConnectionException {
try {
zebraPrinter.storeImage("R:TEMP.PCX", new ZebraImageAndroid(bitmap), 496, 358);
zebraPrinter.getConnection().write("! U1 setvar \"device.languages\" \"CPCL\"\r\n".getBytes());
zebraPrinter.getConnection().write("! U1 do \"file.delete\" \"R:TEMP.PCX\"\r\n".getBytes());
} catch (ConnectionException | ZebraIllegalArgumentException e) {

I saw that in previous topics they suggested using this code in the connection class:

public class ConnectionZebraPrint {
private static final String TAG = ConnectionZebraPrint.class.getSimpleName();

public static ZebraPrinter getZebraPrinter() throws ConnectionException, ZebraPrinterLanguageUnknownException {
Connection printerConnection;
printerConnection = new BluetoothConnection(PrintUtils.getMacAddress());
if (printerConnection.isConnected()) {
return ZebraPrinterFactory.getInstance(PrinterLanguage.CPCL, printerConnection);
return null;

I was not successful on the zq520 and zq520 printers. I configured the printers in Zebra Setup Utilities with the respective drivers for CPCL.
When I debug the code the image is captured normally but it doesn't appear on the invoice, what could be happening? do I need to configure the R: on the ZQ521?

The only way to print an image on the zq521 and 520 that I could was using the following code:

zebraPrinter.printImage( new ZebraImageAndroid(bitmap), 1, 1,496, 358, false);

But the image is printed on a separate sheet...
Could someone help me with this question?

Submitted by SSi1 on July 29, 2021 Permalink

Both ZQ520 and ZQ521 are in ZPL mode by default. Though they both support CPCL by configuring device.languages to CPCL, it's recommended to use ZPL with these Link-OS printers. In the Link-OS SDK for Android, there is a GraphicsUtil class, in which there are a number of methods to print image. The zebraPrinter.printImage() is one of the methods in  GraphicsUtil class. The reason the image is printed on a separate label in your case is because you passed false for the insideFormat parameter of zebraPrinter.printImage(). If you want to print the image as part of a label, you need to pass true for the insideFormat parameter. Here is the pseudo code.

String firstHalfOfZPL = "^XA .....";
String secondHalfOfZPL = "....^XZ";

ZebraPrinter printer = ZebraPrinterFactory.getInstance(connection);

// Send the first half of the ZPL to the printer

// Send your image as part of the ZPL label to the printer with true for the insideFormat parameter
zebraPrinter.printImage( new ZebraImageAndroid(bitmap), 1, 1,496, 358, true);

// Send the 2nd half of ZPL to the printer


Submitted by guilherme.dell… on July 29, 2021 Permalink

Thank you for your attention SSi1
I tried using it with "true", with cpcl the printer prints a bunch of binary nonstop, I can only pass the image file to zpl and the rest of the invoice print to cpcl?
The problem with moving to zpl is that the code is legacy and is all done using cpcl..

Submitted by SSi1 on July 30, 2021 Permalink

To support CPCL, you need to first set the device.languages to CPCL on the ZQ521 printer. Then you need to get the printer instance for the CPCL printer as following:

ZebraPrinter printer = ZebraPrinterFactory.getInstance(CPCL, connection); // Get CPCL printer

Then send the 1st half of the CPCL, and followed by sending the image with printer.printImage() with true for insideFormat, and the 2nd part of the CPCL.

Submitted by guilherme.dell… on August 06, 2021 Permalink

Hi, I came back here to share my solution:
Using the code I described at the beginning of the post I made a small change in my cpcl class that prints the water bill

//I used the following code in the invoice layout to print the image
PCX 40 133 TEMP.PCX;

//It was only necessary to add this zpl code, and configure the printer drivers for cpcl