Android 在蓝牙热敏打印机上打印条形码
我使用蓝牙热敏打印机,能够打印普通文本和发票。但我不能打印条形码 我正在用ZXING库生成条形码Android 在蓝牙热敏打印机上打印条形码,android,bluetooth,barcode,thermal-printer,Android,Bluetooth,Barcode,Thermal Printer,我使用蓝牙热敏打印机,能够打印普通文本和发票。但我不能打印条形码 我正在用ZXING库生成条形码 OutputStream os = mBluetoothSocket.getOutputStream(); String text = mEditText.getText().toString(); MultiFormatWriter multiFormatWriter = new MultiFormatWriter(); BitMatrix bitMatrix = multiFormatWr
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
如何使用相同的逻辑打印位图
我试过一些代码,比如
int size = bitmap.getRowBytes() * bitmap.getHeight();
ByteBuffer byteBuffer = ByteBuffer.allocate(size);
bitmap.copyPixelsToBuffer(byteBuffer);
byte[] byteArray = byteBuffer.array();
os.write(byteArray);
但这给了一个空白打印和滚动继续滚动
我正在使用Godex-MX30打印机您需要告诉打印机您正在发送要打印的图像,并指定如何打印 通常,这是通过ESC/POS代码完成的。大多数这样的打印机使用ESC/POS代码 ESC*是如何指定的。你可以看看这个问题或这个问题中的许多例子 有关更多信息,请参阅精工爱普生
不确定该打印机,但许多热敏收据打印机也支持使用Esc/Pos代码创建和打印条形码。您可以尝试以下操作。询问打印机制造商。供应商不支持Android应用程序的开发人员,而且此打印机可以使用play store的第三方应用程序打印条形码: