質問

I want to print a code 128 barcode using the Zebra's EM 220 SDK for Android.
I tried to print it using the PrintBarcode() method like this :

BxlService bxl = new BxlService();
bxl.Connect(macAddress);
String data = "123589647525";
bxl.PrintBarcode(data.getBytes(), data.length(), BxlService.BXL_BCS_Code128, 100, 3, 0, BxlService.BXL_BC_TEXT_NONE);
bxl.Disconnect();

but the printed code can't be scanned by Android scan applications, like ZXing.

After searching on the web, I understood data had to be formatted (even if I am a little surprised Zebra SDK doesn't do that...) and found the barcode4j library that help to encode data. However, even with the library, the printed barcode can't be scanned.

BxlService bxl = new BxlService();
bxl.Connect(macAdress);
DefaultCode128Encoder dce = new DefaultCode128Encoder();

String data = "123456679857";
int[] i = dce.encode(data);

    String barcode = "";
for (int j : i) {
    barcode += j;
}
bxl.PrintBarcode(barcode.getBytes(), barcode.length(), BxlService.BXL_BCS_Code128, 100, 3, 0, BxlService.BXL_BC_TEXT_NONE);
bxl.Disconnect();

So, my question is simple : how to print code 128 barcode using the Zebra's EM 220 SDK for Android ?

役に立ちましたか?

解決

Finally, I have found a workaround.
I use ZXing to encode my data, create a Bitmap with the barcode, save the Bitmap as a file before printing it with the printImage() method.

It works, but if someone knows how to use the printBarcode() method, I'd appreciate he tells me how to do.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top