Anyone got any experience of printing from within a J2EE app? We have stored against our user records a "print address" fields which points to a networked printer. I need to fire off print jobs from within the Session Facade which will spool to this named printer. All clients will be on the same network (though not necessarily in the same domain) - the app server will be on the same network too. This needs to be 100% cross-platform (Linux, Windows, UNIX - the lot) I know that there is a Java Print Service which I understand is primarily for AWT/Swing client-apps. Has any one used it from the server side? Is is possible? Any gotchas I should watch out for? Or is it just a silly idea? Any ideas/experience is very appreciated.
Any kind of IO activity is not recommended by the EJB Specs due to portability issues. Isn't printing a type of IO activity?
Joined: Mar 04, 2004
Yes - though that doesn't necessarily stop you doing it! However - I was going to do it through my own JCA resource manager, but I'm not sure if its worth writing this unless the print service stuff is good enough to use. I'm beginning to discover it maybe is not. So if anyone has had a similar piece of functionality to implement (i.e. the app server building documents and scheduling them jobs on one of a number of networked printers) I'd be very interested to hear about it.
The Java Print Service API (JSR-006) allows printing pretty much anything -- as long as you make your "anything" implement the correct interfaces... There's a nice example in the user guide. As to where you should invoke the Java Print Service API from, I'd say create a printable document (javax.print.Doc), put it into a JMS queue, and let an MDB make the call to the JPS API for the actual printing. Then again, I'm really not aware of how resource intensive the actual print call is so maybe it would be ok to leave the MDB out of the picture and let the EJB do everything.
Cheers for your reply. I had started like this - print message to MDB, MDB doing the actual Printing service stuff. But I was finding that there are problems with what the avaliable print services can actually do. E.g. despite having a pretty bog-standard printer/printer driver and the app running on Windows XP, a lot of the defined attributes were not supported by the underlying print service (I couldn't enforce paper size, or orientation, or number of copies etc.) What I am finding is that despite the Print Service offering a platform independent route into avaliable printing services, the actual functianality is very much limited by the printer driver. No big suprise there, its just *how* limitied it is that is the problem. Looks like I might have to give this up.
By the way, is JSP part of J2EE, and isn't there a print option on a web browser. I am sure, your print batch function can not be accomplished by the above. But I am just replying to "Printing not allowed in J2EE" comments. Dan.
Indeed it is Dan, and that would be the simple way of doing it. Unfortunately we need people to be able to send print jobs to remote printers without having the configuration overhead of ensuring that every client has correctly configured the avaliable printers in their OS. Also, the client won't necessarily know the action they perform in the app results in a printout to another user, most probably in a completely different location from them.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com