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());
bitmap.recycle();
} catch (ConnectionException | ZebraIllegalArgumentException e) {
e.printStackTrace();
}
}
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());
printerConnection.open();
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?
5 Replies
In the water bill class:
PCX 40 133 !
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.
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..
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:
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.
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
^XA^FO0,0^IMR:TEMP.PCX^XZ