0

我需要从 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”条形码,但事实并非如此。与打印机连接成功;即使我可以使用此命令打印文本但不能打印条形码。有没有人用这种方法和打印机打印条形码的运气更好?感谢您的帮助和评论。

4

2 回答 2

0

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

String NUL = new String(new byte [] {0x00});
outputstream.write(NUL.getBytes());
于 2015-10-05T08:47:03.307 回答
0

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

        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);
于 2017-01-05T18:58:41.603 回答