title: How print invoice receipt using bluetooth thermal printer
body: <p>I have to print invoice receipt using thermal printer.
  I have used <a href="http://www.zjiang.com/product.asp?cat_id=26&amp;name=&amp;class_id=74" rel="nofollow noreferrer">Zjiang Thermal printer</a> to print receipt.
  They also provide there <a href="https://drive.google.com/file/d/0B77sjXvrRR-_WVA1Rnh0a0QtYTA/view?usp=sharing" rel="nofollow noreferrer">manual</a> &amp; demo project.
  In demo project they use a libray "btsdk.jar" to implement connection &amp; print.</p>
  
  <p>I have successfully establish connection between printer &amp; android device.
  But there is no guideline for <strong>text alignment (center, left, right) &amp; cell width, height.</strong></p>
  
  <p>I   <a href="https://stackoverflow.com/questions/14285822/format-text-in-bluetooth-printer">have try it</a>. It only change text height by changing format<a href="https://drive.google.com/file/d/0B77sjXvrRR-_WVA1Rnh0a0QtYTA/view?usp=sharing" rel="nofollow noreferrer">2</a> variable.</p>
  
  <p><strong>How I print invoice by bluetooth printer.</strong></p>
  
  <p><strong>please also explain this section-</strong></p>
  
  <pre><code> byte[] cmd = new byte[3];
   cmd[0] = 0x1b;
   cmd[1] = 0x21;
   cmd[2] |= 0x10;
  </code></pre>
  
  <p>cmd<a href="https://drive.google.com/file/d/0B77sjXvrRR-_WVA1Rnh0a0QtYTA/view?usp=sharing" rel="nofollow noreferrer">2</a> - used for change font height
  what is use of cmd[0] &amp; cmd<a href="http://www.zjiang.com/product.asp?cat_id=26&amp;name=&amp;class_id=74" rel="nofollow noreferrer">1</a></p>
  
  <p><strong>code to send Printing message to bluetooth Printer In Demo Project</strong></p>
  
  <pre><code> 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] &amp;= 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&amp;D,manufacturing,marketing of thermal printers and barcode scanners.\n\n";
   mService.sendMessage(msg,"GBK");
  </code></pre>
  
  <p><strong>Print Info-</strong></p>
  
  <pre><code>       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
  </code></pre>
  
  <p><strong>Invoice Receipt</strong></p>
  
  <p><img src="https://i.stack.imgur.com/4IDiZ.png" alt="enter image description here"></p>