6

I want to print file from android application.For the same , after searching on google,I found some useful information that i will have to use IPP (Internet Printing Protocol) with HTTP. And I am new to ipp but i have worked with HTTP. So can anybody help me for the same ? Can anybody give me some useful information OR links? Thanks in advance ?

Luc Touraille
  • 79,925
  • 15
  • 92
  • 137
Ramesh Solanki
  • 2,961
  • 4
  • 28
  • 44

3 Answers3

2

You need to make an HTTP PUT request with some special features, you must:

  • use the port 631 instead of 80 (unless it's explicitly specified of course).
  • rewrite the url in the header (i.e. ipp:// => http://).
  • protocol ID is IPP/1.1.
  • you must authenticate via a challenge method.

OTOH, the request/response format used in the body is binary, so you should really really read the RFC. Besides that, it's quite simple, all you need is job and printer URIs, and then you just send properly encoded data.

Ismael Luceno
  • 2,055
  • 15
  • 26
  • Thanks for your reply ! Can you give me hint how to make request using header ipp:// in android as i only have ip address of printer ? – Ramesh Solanki Dec 20 '11 at 06:15
  • that's all you need, `ipp://ip:631` in the body and `http://ip:631` in the HTTP header... just open a socket and start writing... – Ismael Luceno Dec 20 '11 at 06:29
  • 2
    Is there any link to get sample code to make above request ? Because I am not able to code to open socket in android.Can you please give me such information ? – Ramesh Solanki Dec 20 '11 at 06:43
  • Is it correct code for me ?http://www.android10.org/index.php/forums/46-networking-a-database/1688-android-socket-program-java-to-print-to-tcpip-printer – Ramesh Solanki Dec 20 '11 at 09:02
  • If you don't care about compatibility, using a CGI could be a good idea. – Ismael Luceno Dec 20 '11 at 23:02
  • You may want to take a look at the `gnu.javax.print.IppPrintService` class. It may or may not work on Android... I've had no chance to try it. – Ismael Luceno Dec 20 '11 at 23:08
  • gnu.javax.print.IppPrintService is not available in android.Is there any other way to do it ? – Ramesh Solanki Dec 21 '11 at 04:30
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/6027/discussion-between-ramesh-solanki-and-ismael) – Ramesh Solanki Dec 21 '11 at 05:22
  • Is it correct code ? http://www.java2s.com/Open-Source/Java-Document/Apache-Harmony-Java-SE/org-package/org.apache.harmony.x.print.ipp.htm – Ramesh Solanki Dec 21 '11 at 13:14
0

You can look at this sample http://code.google.com/p/jspi/source/browse/trunk/jspi/src/main/java/de/lohndirekt/print/examples/SimpleDocExample.java. It is a Java library for IPP.

Horcrux7
  • 23,758
  • 21
  • 98
  • 156
  • 1
    jspi is based on javax.print which is unsupported on android: http://stackoverflow.com/questions/4418530/how-compatible-is-the-java-implementation-of-android-exactly/4419657#4419657 – IPP Nerd May 22 '16 at 17:17
0

Using ipp-client-kotlin printing a file can be implemented like this:

IppPrinter("ipp://colorjet.local/ipp/printer")
    .printJob(File("A4-blank.pdf"))
    .waitForTermination()
IPP Nerd
  • 992
  • 9
  • 25