2015-05-18 245 views
14

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

我已成功建立打印机& android设备之间的连接。 但是没有关于文本对齐(中心,左,右)&单元宽度,高度的指南。

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

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

也请说明本条

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

CMD 2 - 用于更改字体高度 有什么用CMD [0] & CMD 1

代码发送印刷消息到蓝牙打印机演示项目

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 

发票收据

enter image description here

+0

从哪里我可以下载这个SDK? – Amalo

+0

编程手册在这里http://www.issyzonepos.com/uploadfile/downloads/58MMPrinter%20Programmer%20Manual-20150312.pdf –

+0

您是否成功打印过收件? –

回答

4

我发现下面的图片在互联网上的文本对齐方式。希望它可以帮助

enter image description here

+0

谢谢。它适用于文本alignment.I已获得一组命令https://www.sparkfun.com/datasheets/Components/General/Driver%20board.pdf您可以建议以表格格式的打印数据。 – mukesh

+0

我还没有找到任何与表格相关的东西,你必须使用标准命令来建立表格。 –

+0

如同细节部分,该命令仅在标准模式下在行首开始处理时启用。我们无法为一条线提供多重对齐。我们为行设置对齐方式。然后我们如何在一行中打印左边和右边的一个字母。 – mukesh

0

您可以使用此

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

归功于莱昂纳多Sapuy和他原来的Q/A Format text in bluetooth printer 并感谢穆尔塔扎胡尔希德·侯赛因送我到它