Android 使用 Bixolon SPP-R200II 进行条码打印

Android barcode printing with Bixolon SPP-R200II

我需要通过 android 应用程序在品牌“Bixolon”型号“SPP-R200II”的移动蓝牙打印机中打印条码。使用 Android 的 Bixolon SDK 确实适用于三星 SII,但不适用于摩托罗拉 moto G G2。我决定不使用 SDK,而是根据 Bixolon 的“统一命令手册”向打印机发送命令。我正在使用这些行:

String codigo=”1234567894”;
int GS=29;
int k=107;
int m=5;
byte[] codigobytes=codigo.getBytes();
outputstream.write((byte)GS);
outputstream.write((byte)k);
outputstream.write((byte)m);
outputstream.write(codigobytes);

根据手册,此命令应打印“ITF”条形码,但事实并非如此。与打印机的连接已成功建立;即使我可以使用此命令打印文本但不能打印条形码。 有人用这种方法和打印机打印条形码时运气更好吗?感谢您的帮助和评论。

您在打印条码时遗漏了一个重要的部分。它应该以 NUL 符号结尾。 添加:

String NUL = new String(new byte [] {0x00});
outputstream.write(NUL.getBytes());

这是在我的应用中运行良好的代码:

        ByteArrayOutputStream baos=new ByteArrayOutputStream();
        String barcode="12345";
        int GS=29;
        int k=107;
        int m=73;   //73 code128
        int n=barcode.length(); //code length
        int h=104;
        int HH=72;
        int Hn=2;
        int height=70;

        // code height=80
        baos.write((byte) GS);
        baos.write((byte) h);
        baos.write((byte)height);

        //width of each bar in barcode to the minimum
          int ESC=29;
          int w=119;
          int n=2;
          baos.write((byte)ESC);
          baos.write((byte)w);
          baos.write((byte)n);

        //Print label below barcode
        baos.write((byte)GS);
        baos.write((byte)HH);
        baos.write((byte)Hn);

        //Print barcode type Code 128
        byte[] codebytes=barcode.getBytes();
        baos.write((byte)GS);
        baos.write((byte)k);
        baos.write((byte)m);
        baos.write((byte)n);
        baos.write(codebytes);
    // Paper feed
        int ESC=27;
        int d=100;
        int n=2;
        baos.write((byte)ESC);
        baos.write((byte)d);
        baos.write((byte)n);