title: Use IPP(Internet Printing Protocol) or LPR(Line printer Remote) to print file in android
body: <p>My requirement is to print a file from an android device without using any cloud based service.</p>
  
  <p>I have been able to achieve it using <strong>"Raw" print protocol</strong> i.e by simply sending the file to printer's IP address at Port <strong>9100</strong>. Here is the code snippet for that:</p>
  
  <pre><code> client = new Socket(ip,port); //Port is 9100
   byte[] mybytearray = new byte[(int) file.length()]; //create a byte array to file
   fileInputStream = new FileInputStream(file);
   bufferedInputStream = new BufferedInputStream(fileInputStream);
   bufferedInputStream.read(mybytearray, 0, mybytearray.length); //read the file
   outputStream = client.getOutputStream();
   outputStream.write(mybytearray, 0, mybytearray.length); //write file to the output stream byte by byte
   outputStream.flush();
   bufferedInputStream.close();
   outputStream.close();
  </code></pre>
  
  <p>The problem with "Raw" printing protocol is that there is no way to get the status back from the printer.</p>
  
  <p>So, I recently read about <strong>IPP</strong> and <strong>LDR</strong> using which we can get the status back from printer.</p>
  
  <p>I have tried to find a way to implement them using android but had no success. I have already went through <a href="https://stackoverflow.com/questions/8570882/how-to-use-ippinternet-printing-protocol-with-http-to-print-file-in-android">this answer</a> but had no success in finding my solution.</p>
  
  <p>It will be really helpful if someone can guide me on how to implement IPP or LDR in android.</p>
  
  <p>Thanks in advance!</p>