[英]How print invoice receipt using bluetooth thermal printer
I have to print invoice receipt using thermal printer.我必须使用热敏打印机打印发票收据。 I have used Zjiang Thermal printer to print receipt.
我用过浙江热敏打印机打印收据。 They also provide there manual & demo project.
他们还提供手册和演示项目。 In demo project they use a libray "btsdk.jar" to implement connection & print.
在演示项目中,他们使用库“btsdk.jar”来实现连接和打印。
I have successfully establish connection between printer & android device.我已成功在打印机和 android 设备之间建立连接。 But there is no guideline for text alignment (center, left, right) & cell width, height.
但是没有关于文本对齐(中心、左、右)和单元格宽度、高度的指南。
I have try it .我试过了。 It only change text height by changing format 2 variable.
它仅通过更改格式2变量来更改文本高度。
How I print invoice by bluetooth printer.我如何通过蓝牙打印机打印发票。
please also explain this section-还请解释这一部分-
byte[] cmd = new byte[3];
cmd[0] = 0x1b;
cmd[1] = 0x21;
cmd[2] |= 0x10;
cmd 2 - used for change font height what is use of cmd[0] & cmd 1 cmd 2 - 用于更改字体高度 cmd[0] 和 cmd 1 的用途
code to send Printing message to bluetooth Printer In Demo Project在演示项目中向蓝牙打印机发送打印消息的代码
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");
Print Info-打印信息-
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
Invoice Receipt发票收据
I have found the following image over the internet for Text Alignment.我在互联网上找到了以下用于文本对齐的图像。 Hope it helps
希望能帮助到你
you can use this你可以用这个
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");
}
credit goes to Leonardo Sapuy and his original q/a Format text in bluetooth printer and thanks to Murtaza Khursheed Hussain for sending me to it归功于 Leonardo Sapuy 和他在蓝牙打印机中的原始 q/a 格式文本,并感谢 Murtaza Khursheed Hussain 将我发送给它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.