我正在研究中文蓝牙热敏打印机Model:SCAN-X
,问题是长字符串的条形码是不可扫描的:
0123456789
- 印刷和可扫描abcdefghijklmno
- 印刷而不可扫描INV-1-48
- 印刷和可扫描INW-0001-0000000047
---印刷而不可扫描INW-001-0123456789
---印刷和可扫描INW-0001-123456789
---印刷而不可扫描我有点困惑我的代码有问题吗?
private void printBarcodeTest() {
OutputStream out = null;
try {
if ((socket == null) || (!socket.isConnected())) {
socket = BluetoothUtil.getSocket(mBluetoothPrinterDevice);
}
out = socket.getOutputStream();
} catch (IOException e) {
e.printStackTrace();
}
// String barcodeContent1 = "INW-1-47"; // this is printing fine
String barcodeContent1 = "INW-0001-0000000047"; // this is printing, but not readable by barcode scanner
byte[] format = new byte[]{
0x1D, // GS
0x6B, // k
(byte) 73, // m (2) this is CODE_128
(byte) barcodeContent1.length() // n (number of barcode data bytes)
};
byte[] data = ESCUtil.byteMerger(new byte[][]{
format,
barcodeContent1.getBytes(StandardCharsets.UTF_8) //d1...dn
});
if (out != null) {
// init printer
// ESC , @
writeOutStream(out, new byte[]{0x1B, 0x40});
// // left margin
// // GS , L , nL , nH
// writeOutStream(out,new byte[]{ 0x1D , 0x4C ,(byte) (0 % 256),(byte) (0 / 256)});
// set alignment to center
// ESC ,a , n
writeOutStream(out, new byte[]{0x1B, 0x61, (byte) 1});
// set HRI position
// GS , ! , n
writeOutStream(out, new byte[]{0x1D, 0x48, (byte) 2});
// set height
// GS , h , n
writeOutStream(out, new byte[]{0x1D, 0x68, (byte) 2});
// set width
// GS , w , n
writeOutStream(out, new byte[]{0x1D, 0x77, (byte) 16);
// set data to print
writeOutStream(out, data);
// set next line feed
// LF
writeOutStream(out, new byte[]{0x0A});
// print n dots in feed
// ESC , J , n
writeOutStream(out, new byte[]{0x1B, 0x4A, (byte) 160});
}
try {
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
输出:
有谁可以看看并指导我?
好吧,它不是安静的区域或边界框或软件。问题出在打印头上。酒吧之间有太多的流血。如果您打印出100个'... 0047'代码,可能只有一小部分会扫描。
您的打印头(热,我认为?)不会在杆之间冷却到足以留下空白区域。这可能是因为纸张对热太敏感,可能是因为打印头不是设计用于这种紧密间隔,或者它可能是不好的打印头。以下是您可能想要尝试的一些事项: