title: Android How to print through Bluetooth printer with text alignment and also using table style?
body: <p>I am trying to print some information through bluetooth printer. I can print plain text. But I can't add any alignment and text format. Also i want to print some data like tableview.</p>
  
  <p><strong>Text format and alignment should be like this:-</strong></p>
  
  <p><a href="https://i.stack.imgur.com/NljJJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NljJJ.jpg" alt="enter image description here"></a></p>
  
  <p><strong>Table formatted data should be like this:-</strong></p>
  
  <p><a href="https://i.stack.imgur.com/sbvYt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sbvYt.jpg" alt="enter image description here"></a></p>
  
  <p>I need some <strong>help</strong> Please.</p>
  
  <p><strong>Here i include my code which i try:-</strong></p>
  
  <pre><code>    String titleStr = "Title" + "\n\n";
      StringBuilder contentSb = new StringBuilder();
      contentSb.append("Item1      : 1221" + "\n");
      contentSb.append("Item2      : test" + "\n");
      StringBuilder content2Sb = new StringBuilder();
      content2Sb.append("BANK  : Us. 1.600" + "\n");
      String message  = "This is for test." + "\n\n";
      long milis      = System.currentTimeMillis();
      String date     = DateUtil.timeMilisToString(milis, "dd-MM-yy / HH:mm")  + "\n\n\n\n";
  
      byte[] titleByte    = titleStr.getBytes();
      byte[] content1Byte = contentSb.toString().getBytes();
      byte[] messageByte  = message.getBytes();
      byte[] content2Byte = content2Sb.toString().getBytes();
      byte[] dateByte     = date.getBytes();
      byte[] totalByte    = new byte[titleByte.length + content1Byte.length + messageByte.length +
                      content2Byte.length + dateByte.length];
  
      int offset = 0;
      System.arraycopy(titleByte, 0, totalByte, offset, titleByte.length);
      offset += titleByte.length;
      System.arraycopy(content1Byte, 0, totalByte, offset, content1Byte.length);
      offset += content1Byte.length;
      System.arraycopy(messageByte, 0, totalByte, offset, messageByte.length);
      offset += messageByte.length;
      System.arraycopy(content2Byte, 0, totalByte, offset, content2Byte.length);
      offset += content2Byte.length;
      System.arraycopy(dateByte, 0, totalByte, offset, dateByte.length);
  
      mmOutputStream.write(totalByte);
  </code></pre>