This post originated from an RSS feed registered with Java Buzz
by Marc Logemann.
Original Post: The World of Java printing
Feed Title: Marc's Java Blog
Feed URL: http://www.logemann.org/day/index_java.xml
Feed Description: Java related topics for all major areas. So you will see J2ME, J2SE and J2EE issues here.
6 hours of real fun today and no coding at all, just plain research work. I am involved in some project which requires printing from a java server application. Buf before digging into java, i checked the printer manufacturers site what the Ethernet-Printserver is capable of, the list was quite impressive:
Print Protocols and Methods (all simultaneously active):
TCP/IP: LPR/LPD, Telnet, FTP, IPP v1.0, Raw printer port (port 9100)
BTW we are speaking of a thermal direct printer from a company called Zebra, i will come to this later on..
Not being the printer guy, i checked most of the protocols to see how they integrate into java. FTP is of course one of the easiest things to integrate, but the resulting software should be responsive, i dont think FTP is the best way to do application-printer communciation. Telnet is an even more obscure choice, so i trashed that option instantly. Raw printer port seems to be an option when you want to play around with sockets, its a choice, but if you want support more printers in the future, this is not the best one. The remaining two are quite interessting: LPR/LPD is widely used and is available on all platforms but the same goes for IPP, with the advantage of IPP to be even more standardized and with better tunneling capabilties.
So to me, LPR or IPP are good choices and i will see later on how its going. As we all know, printing has been a cruel story in the java world for many years, with 1.4 we got the new "Java Printing System" API. But Sun seemed to have forgotten to include an IPPPrinterServiceLocator in the J2SE, after an extensive search i found this:
Have not tried it yet, but it seems to solve my problem. When using LPR, the default discovery service should locate the printer, but this is also a wild guess, as so many others are wildguessing when it comes to printing from within java.
Another quite interessting resource in the LPR/LPD area was this one:
Given the case i can finally send data to the various network printers, one would say that most of the work is done. But i have to submit a totally proprietary printer language called EPL2 - Eltron Programming Language. Eltron was the former companyname of zebra (or they aquired eltron - dont know). With EPL2 you submit an ASCII file with various control codes to print barcodes or other stuff which you cant express via ASCII ;-) But i think even its proprietary, this is easier than the communication handling.
Soon i will get a test device, then i will transfer this research knowledge into real life, i will write a follow up on this blog then...