This post originated from an RSS feed registered with Java Buzz
by Marc Logemann.
Original Post: Obstacles with Java cross platform printing
Feed Title: Logemann Blog
Feed URL: http://feeds.feedburner.com/LogemannBlog
Feed Description: Marc Logemann's thoughts on java and other stuff
To be honest, i am pretty aware of the fact that cross platform printing is an issue with a lot of obstacles for the maintainer (Sun / Oracle) of a language. There are just too many things out of control of SUN. First the whole mess with different printing systems on the various platforms. CUPS on linux and Mac, Windows Spool on MS Windows and other system on other platforms. Here you have to maintain different APIs, even though all systems should understand IPP, its nevertheless kind of proprietary to use the systems as i will point out.
Take CUPS for example. Lately i installed latest Ubuntu Server distro with a vanilla install. After that i installed cups via "apt-get install cups". If you think that you can print with java with this configuration (tested with OpenJDK), you are wrong. You also need to install "cups-bsd". Took me hours to get that. When you see the first pages flying out of your printer and you start getting a smile on your face, it will come to an abrupt end when you fiddle around with IPP printer properties. For instance, try to use one of those Tray properties to print to a different tray. You wont laugh at that mess for sure.
While we speak about printing, we also face the issue of fonts. With SUN JRE, you had at least one font family which was packaged with the JRE itself. With OpenJDK you dont have that. You have bindings to system based fonts like DejaVue or something. This means you simply cant rely on an installed font when developing java products. "SHIP IT OR DIE" is the answer for all those who wonder what kind of font one should use.
We at LOGENTIS thought that we could circumvent all the hassles by just creating a PDF (of course the font issue is nevertheless there) and send that PDF directly to a network printer which is capable of rastering PDFs. Nice idea and it worked of course but soon you will notice that you traded some problems away and got others for free. You will notice that without having a spooler system, things like concurrent access is a major issue.
One thing which might solve a lot of issues is to combine the PDF approach with a custom developed IPP based print spooler which is part of the application itself. This way you could bypass legacy spoolers like CUPS or WinSpool but still use a spooler system which handles job management. Of course you still need a PDF capable printer which are not that easy to find. And its worth to mention that developing a good IPP based spooler is not something you do in a week.
One thing that is bullet proof is not to print at all and send PDFs to your users via email or download and let them do the printing on the client. This works for apps with user interaction but not for server side apps which run without user interaction. What ever you will do, keep in mind that printing will be tough, at least when you have a cross platform product like we have with NETVERSYS. In the end its possible to cirumvent all issues some way or the other but it will never be fun and sooner or later you will hate the whole printing topic.