【问题标题】:ESC/POS Long String Barcode Not ScanableESC/POS 长字符串条码不可扫描
【发布时间】:2019-03-05 08:23:09
【问题描述】:

我正在开发中文蓝牙热敏打印机Model:SCAN-X,问题是长字符串的条形码无法扫描:

  • 0123456789 -- 打印和扫描
  • abcdefghijklmno -- 打印且不可扫描
  • INV-1-48 -- 打印和扫描
  • INW-0001-0000000047 --- 已打印且不可扫描
  • INW-001-0123456789 --- 打印和扫描
  • INW-0001-123456789 --- 已打印且不可扫描

这里是打印机 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();
        }
    }

输出:

谁能帮帮我看看?

【问题讨论】:

  • 如果我能看到扫描的图片,那可能会有所帮助。有时两边没有足够的安静区域,有时会出现边界框问题。
  • 附上一张图片@BrianAnderson

标签: android thermal-printer barcode-printing escpos


【解决方案1】:

好的,不是静区、边界框或软件。问题出在打印头上。钢筋之间出血过多。如果您打印出 100 个“...0047”代码,也许其中一小部分会被扫描。

您的打印头(我认为是热敏打印头?)在条之间没有充分冷却以留下空白。这可能是因为纸张对热太敏感,可能是因为打印头不是为如此紧密的间距设计的,或者可能是打印头坏了。 以下是您可能想尝试的一些事情:

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

【讨论】:

  • 当我增加宽度并给出相同的结果时,行变得更加拥挤,因为我猜它的 58 毫米打印机的宽度最大为 384 像素,我给单位 16,其中 1 个单位是 25 像素,所以 16 *24 = 384px,我已经在同一家公司的 2 台打印机上尝试过,结果相同
  • 我不知道还能告诉你什么,除了问题似乎在条形之间流血,尤其是在狭窄的空间中。可扫描性与对比度有关,虽然人眼如果看起来足够近,可以将条之间的灰色区分为不是黑色,但扫描仪将无法获得足够的光吸收差异以将电压提高到足以记录“白色” “ 空间。基材可能是旧的。尝试质量更好的论文可能会有所帮助。
猜你喜欢
  • 1970-01-01
  • 2014-08-25
  • 1970-01-01
  • 2014-01-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-15
相关资源
最近更新 更多