1

I am working with a bluetooth thermal printer and was able to print normal text and invoice's as well. But i am not able to print barcodes.

I am generating barcode with ZXING library

OutputStream os = mBluetoothSocket.getOutputStream();

String text = mEditText.getText().toString();

MultiFormatWriter multiFormatWriter = new MultiFormatWriter();

BitMatrix bitMatrix = multiFormatWriter.encode(text,BarcodeFormat.CODE_128,200,200);

BarcodeEncoder barcodeEncoder = new BarcodeEncoder();

Bitmap bitmap = barcodeEncoder.createBitmap(bitMatrix);

os.write("Hello".getBytes()); //Prints Hello 

How can i print the bitmap using the same logic ?

I have tried some codes like

int size = bitmap.getRowBytes() * bitmap.getHeight();

ByteBuffer byteBuffer = ByteBuffer.allocate(size);

bitmap.copyPixelsToBuffer(byteBuffer);

byte[] byteArray = byteBuffer.array();

os.write(byteArray);

But this gives a blank print and roll keep rolling

I am using Godex-MX30 printer

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Keyur Kariya
  • 69
  • 2
  • 12
  • Ask the printer manufacturer. – CommonsWare Apr 08 '19 at 10:58
  • Do not have Developer support for Android application from the Vendor, also this printer is able to printer barcode using 3rd Part Applications from play store: https://play.google.com/store/apps/details?id=co.com.UtilIntelligenceCPCL_Demo&hl=en – Keyur Kariya Apr 10 '19 at 06:05

1 Answers1

2

You need to tell the printer that you are sending an image to print and specify how to print it.

Typically this is done with ESC/POS codes. Most printers like this use ESC/POS codes.

ESC * is how that is specified. You can look at the many examples in this questions java code or in this one's solution as well.

For more information, see Seiko Epson reference.

Not sure about this printer, but many of thermal receipt printers have support for creating and printing barcodes also using Esc/Pos Code. You could try something like this.