title: How to print tab in printer
body: <p>I have to print receipts through a thermal printer using Java.
  And for the format, I can understand how to print align center base on the manual like below:</p>
  
  <p><strong>center manual:</strong> </p>
  
  <pre><code>[Name] Select justification 
  [Format] ASCII   ESC a n 
           Hex     1B 61 n 
           Decimal 27 97 n 
  [Range] 0 ≤ n ≤ 2, 48 ≤ n ≤ 50 
  [Description] Aligns all the data in one line to the specified position. 
  
   n selects the type of justification as follows: 
     n    Justification 
   0, 48 Left justification 
   1, 49 Centering 
   2, 50 Right justification 
  </code></pre>
  
  <p>so the code below works:
  <strong>center code:</strong></p>
  
  <pre><code>    private void printAlignCenter(){
          byte[] cmd = new byte[3];
          cmd[0] = 0x1B;
          cmd[1] = 0x61;
          cmd[2] = 0x01;
          wfComm.sndByte(cmd);
      }
  </code></pre>
  
  <p>now, the tab setup and tab manual:
  <strong>tab manual:</strong> </p>
  
  <pre><code>[Name] Set horizontal tab positions 
  [Format] ASCII   ESC D n1...nk NUL 
           Hex     1B 44 n1...nk 00 
           Decimal 27 68 n1...nk 0 
  
  [Range] 1 ≤ n ≤ 255 
          0 ≤ k ≤ 32 
  
  [Description] Sets horizontal tab positions. 
          ▪ n specifies the column number (counted from the beginning of the 
            line) for setting a horizontal tab position. 
          ▪ k indicates the total number of horizontal tab positions to be set. 
  
  [Name] Horizontal tab 
  [Format] ASCII HT 
           Hex 09 
           Decimal 10 
  [Description] Moves the print position to the next horizontal tab position
  [Notes] ▪ This command is ignored unless the next horizontal tab position 
            has been set. 
  </code></pre>
  
  <p>but the code below not works:
  <strong>tab code:</strong></p>
  
  <pre><code>    private void printTabEnable(){
          byte[] cmd = new byte[3];
          cmd[0] = 0x1B;
          cmd[1] = 0x44;
          cmd[2] = 0x28;
      //     cmd[3] = 0x08;//08//10
      //     cmd[4] = 0x12;//12//20
              wfComm.sndByte(cmd);
      }
  
      private void printTab(){
          byte[] cmd = new byte[1];
          cmd[0] = 0x09;
          wfComm.sndByte(cmd);
      }
  </code></pre>