0

I'm working on Chinese Bluetooth thermal printer Model:SCAN-X, Problem is barcodes for long strings are not scannable:

  • 0123456789 -- printed & scannable
  • abcdefghijklmno -- printed & not scannable
  • INV-1-48 -- printed & scannable
  • INW-0001-0000000047 --- printed & not scannable
  • INW-001-0123456789 --- printed & scannable
  • INW-0001-123456789 --- printed & not scannable

Here is specified guide in ESC/POS doc of printer scan-x-barcode-doc

I am bit confused is there something wrong with my code?

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

Output:

Scan-X_output

Can anyone please take a look and guide me?

Zulqurnain Jutt
  • 298
  • 3
  • 20

1 Answers1

0

Okay, it isn't the quiet zones or bounding box or the software. The problem is with the print head. There is too much bleed between the bars. If you printed out 100 of the '...0047' codes, maybe a fraction of them would scan.

Your print head (thermal, I think?) isn't cooling down enough between the bars to leave white spaces. This may be because the paper is too sensitive to heat, it may be because the print head is not designed for such tight spacing, or it may be a bad print head. Here are some things you might want to try:

  1. Another printer, if one is available, this might help you isolate a bad printer.
  2. Scaling up the barcode width about 50%, increasing the space between bars. Try "writeOutStream(out, new byte[]{0x1D, 0x77, (byte) 24);"
  3. Use Code 128C for the large numeric portion on the right. I'm not sure how to switch to Code 128C from Code 128B using that setup, but it could shorten the entire barcode symbol by 4 characters.
Brian Anderson
  • 1,661
  • 1
  • 17
  • 27
  • line become more congested when I increase the width and give same result because its 58mm printer I guess which have a max of 384px as a width, where I am giving unit 16 where 1 unit is 25px so 16*24 = 384px , and i have tried this in 2 printers of same company same result – Zulqurnain Jutt Mar 07 '19 at 07:02
  • I don't know what else to tell you other than the problem seems to be bleeding between the bars, especially over thin spaces. Scannability is all about contrast, and while the human eye, if it looks close enough, can distinguish the grey between the bars as not black, the scanner will not pick up enough difference in light absorption to raise the voltage enough to register a "white" space. It may be possible that the substrate is old. Trying a better quality paper may help. – Brian Anderson Mar 07 '19 at 13:13