title: How to print from the Thermal Printer in Android?
body: <p>I am working on an application for an Android device that will have a built in line printer. I have to interact with this printer and use it to print the details on receipt and then with cutter cut that receipt automatically. I have seen some ESC commands in it, but I don't know how to execute these ESC commands. </p>
  
  <p><strong>I have three main issues regarding the Casio Device Printer :</strong></p>
  
  <p><strong>1.I have used the printing code for Build in printer, but after printing the cutter is not activated</strong></p>
  
  <pre><code>BuildinEx840 ex840 = new BuildinEx840();
  int response = ex840.open();
  System.out.println("ex840 open:" + response);
  
  byte[] set = {
      'N', 'A', 'R', 'E', 'S', 'H', 'S', 'H', 'A', 'R', 'M', 'A', (byte) 0x0d, (byte) 0x0a
  };
  
  try {        
  
      ex840.write(set);   
  
  } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
  }
  
  try {
  
      response = ex840.getEndStatus();
      System.out.println("getEndStatus:" + response);
      response = ex840.initCutter();
      ex840.close();    
      System.out.println("initCutter:" + response);
  
  } catch (Exception e) {         
      e.printStackTrace();         
  }
  </code></pre>
  
  <p><strong>2. I don't know how to send ESC commands to the Printer in android</strong></p>
  
  <p>There are number of commands like below  </p>
  
  <pre><code>ESC FF DataPrint,
  [code]  &lt;1B&gt;H&lt;OC&gt;H,
  [Function] Print all the data in the print area collectively.
  </code></pre>
  
  <p>How can we execute these ESC commands in android by programming ??</p>
  
  <p>3.<strong>I don't know how to print the receipt in the required format</strong></p>
  
  <p>There are some ESC commands are available for providing margins from left and right and some other commands. So how can I print the data in some formate and can change the size of the text as well as some other settings of the text to be printed. </p>
  
  <p>Any help is appreciated. </p>