I'm interested in knowing how can my Java program listen to the Print event generated by the underlying OS. As my project is based on Java, the Print job event listener should not be platform depended. To be more specific my program will be running on the background and should be notified of the print job if a user is trying to print pages from MS Word (for an example). The event should notify not only the print job being started but also other details such as No. of pages, the document location etc (if that's possible). A link to complete tutorial or some snippets would be much appreciated. Thanks!
We are a C++ and Java shop. I have written code that does pretty much what you are asking for. It was written in C++ for Win32 (and was a right bugger to get correct - this is one of the least well documented areas of the Win32 API - and different printers send different event streams, so it can be really tough to develop robust print queue handling).
If someone has created a JNI library for doing this stuff (unlikely), there is no way it will be cross-platform. The effort involved would be enormous (different OSes handle print queues and notifications in completely different ways).
My recommendation would be to brush up on your Win32 programming (with C/C++). Once you have things working there, if you absolutely must have them interact with your Java app, you can use JNI to wrap it.
Here's MSDN articles on printer change notification monitoring (you'll have to call OpenPrinter first - but the next call is FindFirstPrinterChangeNotification): http://msdn.microsoft.com/en-us/library/dd162722(VS.85).aspx
If you are trying to support *nix and mac as well, you'll need to dig for those separately. Good luck.