How print invoice receipt using bluetooth thermal printer

mukesh picture mukesh · May 18, 2015 · Viewed 15.8k times · Source

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.

I have successfully establish connection between printer & android device. 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 format2 variable.

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;

cmd2 - used for change font height what is use of cmd[0] & cmd1

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

enter image description here

Answer

Murtaza Khursheed Hussain picture Murtaza Khursheed Hussain · May 25, 2015

I have found the following image over the internet for Text Alignment. Hope it helps

enter image description here