【问题标题】:How print invoice receipt using bluetooth thermal printer如何使用蓝牙热敏打印机打印发票收据
【发布时间】:2015-07-29 12:40:36
【问题描述】:

我必须使用热敏打印机打印发票收据。 我用Zjiang Thermal printer 打印收据。 他们还在那里提供manual 和演示项目。 在演示项目中,他们使用库“btsdk.jar”来实现连接和打印。

我已成功建立打印机和安卓设备之间的连接。 但是没有文本对齐(中心、左、右)和单元格宽度、高度的准则。

have try it。它仅通过更改格式2 变量来更改文本高度。

如何通过蓝牙打印机打印发票。

也请解释一下这部分-

 byte[] cmd = new byte[3];
 cmd[0] = 0x1b;
 cmd[1] = 0x21;
 cmd[2] |= 0x10;

cmd2 - 用于改变字体高度 cmd[0] & cmd1有什么用

在演示项目中向蓝牙打印机发送打印消息的代码

 String msg = "";
 byte[] cmd = new byte[3];
 cmd[0] = 0x1b;
 cmd[1] = 0x21;
 cmd[2] |= 0x10;
 mService.write(cmd);           
 mService.sendMessage("Congratulations!\n", "GBK"); 
 cmd[2] &= 0xEF;
 mService.write(cmd);          
 msg = "  You have sucessfully created communications between your device and our bluetooth printer.\n\n"
      +"  the company is a high-tech enterprise which specializes" +
        " in R&D,manufacturing,marketing of thermal printers and barcode scanners.\n\n";
 mService.sendMessage(msg,"GBK");

打印信息-

       parameters:support to download the Logo trademark
       FontA:12*24 dots,1.5(W)*3.0(H) mm
       FontB:9*17 dots, 1.1(W)*2.1(H) mm
       Simplified/Traditional: 24*24 dots, 3.0(W)*3.0(H)
       Line spacing: 3.75mm (Default)
       Barcode Types:-
       1D Barcode- UPC-A/UPC-E, JAN13(EAN13), JAN8(EAN8), CODE39/ITF, CODABAR,CODE93
       2d Barcode- QR CODE

发票收据

【问题讨论】:

标签: android android-bluetooth thermal-printer


【解决方案1】:

我在互联网上找到了以下用于文本对齐的图像。希望对你有帮助

【讨论】:

  • 谢谢。它适用于文本对齐。我有一组命令sparkfun.com/datasheets/Components/General/Driver%20board.pdf你可以建议以表格格式打印数据吗?
  • 我没有找到任何与表格相关的内容,您必须使用标准命令构建表格。
  • 如详细信息部分所述,该命令仅在标准模式下在行首处理时启用。我们不能为一条线提供多重对齐。我们为行设置对齐方式。然后我们如何在一行中打印一个字母左和另一个右。
  • 您找到打印粗体文本的方法了吗?
  • 阅读下面的答案,希望它有助于“粗体”文本stackoverflow.com/a/15981715/1061944
【解决方案2】:

你可以用这个

void printLine(String txt, char type){
    byte[] format = { 27, 33, 0 };
    byte[] arrayOfByte1 = { 27, 33, 0 };

    if (type == 'b') {
        format[2] = ((byte) (0x8 | arrayOfByte1[2])); //BOLD
    }
    if (type == 'h') {
        format[2] = ((byte) (0x10 | arrayOfByte1[2])); //HEIGHT
    }
    if (type == 'w') {
        format[2] = ((byte) (0x20 | arrayOfByte1[2])); //WIDTH
    }
    if (type == 'u') {
        format[2] = ((byte) (0x80 | arrayOfByte1[2])); //UNDERLINE
    }
    if (type == 's') {
        format[2] = ((byte) (0x1 | arrayOfByte1[2])); //SMALL
    }
    mService.write(format);
    mService.sendMessage(txt,"GBK");
}

感谢 Leonardo Sapuy 和他的原始 q/a Format text in bluetooth printer 并感谢 Murtaza Khursheed Hussain 派我去那里

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-08-27
    • 2018-04-28
    • 2014-06-21
    • 1970-01-01
    • 2019-11-23
    • 2019-01-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多