Listening for a Print Job Event Raised from the File Menu from Java
I am interested to know how my Java program can listen for the Print event generated by the underlying OS. As my project is Java based, the print job event listener should be platform independent. To be more specific, my program will run in the background and should be notified of a print job if the user tries to print pages from MS Word (for example). The event should notify not only the started print job, but also other details such as the number of pages, the position of the document, etc. (If possible). A link to the full tutorial or some excerpts would be appreciated. Thanks!
We are a C ++ and Java store. I wrote some code that does a lot of what you are asking for. This was written in C ++ for Win32 (and was the right searcher to fix this - this is one of the least well documented areas of the Win32 API), and different printers send different streams of events, so it can be very difficult to design a reliable print queue processing).
If someone created a JNI library to accomplish this stuff (unlikely), it won't be cross-platform. The effort involved is going to be huge (different operating systems handle print queues and notifications in very different ways).
My recommendation would be to brush up on your Win32 programs (with C / C ++). If you have something working, if you absolutely must interact with your Java application, you can use JNI to port it.
Here in MSDN articles on print notification change notification (you need to call OpenPrinter first, but the next call is FindFirstPrinterChangeNotification): http://msdn.microsoft.com/en-us/library/dd162722(VS.85).aspx
If you're also trying to support * nix and mac, you'll have to dig for them separately. Good luck.
a source to share