Printing QR Code to Label - Formatting Issues


Audience
Tags

I'm using the java link_os SDK to print QR Codes, over a TcpConnection.attempting to get centered images in the label and one QR Code per label.

ZebraImageI image = ZebraImageFactory.getImage(imageFile.getAbsolutePath());
ZebraPrinter printer = ZebraPrinterFactory.getInstance(printerConnection);
printer.printImage(image, 45, 9, 240, 240, false);

The image prints correctly, however the printer skips a label between printing and the y coordinate is inconsistent. For example, the first will be aligned correctly, the second will be off center towards the bottom, and the third will have the top of the qr code cut off. Between each successful print of a QR Code will be a blank label. I think my issue is that the printer may be in "journal" mode, based upon https://developer.zebra.com/content/zsdk-api-get-media-size-printer. I'm thinking that I can use

SGD.SET( "media.type", "label", printerConnection);

to resolve the issue. I haven't found a table of settings and valid values and am unsure if this is the cause of the issue. Anyone with a better understanding of the link_os confirm this approach or point me in the right direction if I'm off base?

Submitted by SSi1 on May 04, 2022 Permalink

There seems to be two issues associated with what you described. If you want the image and the QR code to be printed on the same label, then you need to pass the "true" flag to the printerImage() API. The value of this flag determines whether the image should be printed by itself (false) or be part of a format being written to the connection (true).

The second issue is the printer calibration. Change the media.type from journal to label is the first step. Then you need to calibrate the printer with the media (roll of labels) installed in the printer. So that the printer can measure the label length accurately. You may also need to check the setting of the media.sense_mode, depending on the bar or gap is used on the media.

Submitted by nathan.schmitz… on May 05, 2022 Permalink

To be clear, the QR code in this case is the image and is being generated via other means.

Setting the media.type to label improved the printing dramatically. We are no longer skipping labels and we seem to be printing consistently on the label. I'm implementing "calibration" features that allow user to configure an x + y offset and update the location where the QR code will print so when the labels are replenished users users can tweak to ensure centered QR Codes.