ESC / POS长字符串条形码不可扫描

问题描述 投票:0回答:1

我正在研究中文蓝牙热敏打印机Model:SCAN-X,问题是长字符串的条形码是不可扫描的:

  • 0123456789 - 印刷和可扫描
  • abcdefghijklmno - 印刷而不可扫描
  • INV-1-48 - 印刷和可扫描
  • INW-0001-0000000047 ---印刷而不可扫描
  • INW-001-0123456789 ---印刷和可扫描
  • INW-0001-123456789 ---印刷而不可扫描

这是打印机scan-x-barcode-doc的ESC / POS doc中的指定指南

我有点困惑我的代码有问题吗?

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();
        }
    }

输出:

Scan-X_output

有谁可以看看并指导我?

android thermal-printer barcode-printing escpos
1个回答
0
投票

好吧,它不是安静的区域或边界框或软件。问题出在打印头上。酒吧之间有太多的流血。如果您打印出100个'... 0047'代码,可能只有一小部分会扫描。

您的打印头(热,我认为?)不会在杆之间冷却到足以留下空白区域。这可能是因为纸张对热太敏感,可能是因为打印头不是设计用于这种紧密间隔,或者它可能是不好的打印头。以下是您可能想要尝试的一些事项:

  1. 如果有另一台打印机,这可能有助于您隔离坏的打印机。
  2. 将条形码宽度放大约50%,增加条形之间的间距。尝试“writeOutStream(out,new byte [] {0x1D,0x77,(byte)24);”
  3. 使用Code 128C作为右侧的大数字部分。我不确定如何使用该设置从Code 128B切换到Code 128C,但它可以将整个条形码符号缩短4个字符。
© www.soinside.com 2019 - 2024. All rights reserved.