Is it possible to cancel a print job once it has already been put into the document queue in windows with java code?
A:
It looks like this is what you're looking for (note that I haven't tested the example myself)
kskjon
2010-10-08 12:16:39
Thanks for finding this. This does seem to work to stop a print job that shows spooling in the document queue but is there a way to cancel the job once it is fully in the print queue? If I press the cancel button in that example code you posted I get: javax.print.PrintException: Job could not be cancelled.
2010-10-08 13:40:18
I guess what I might be looking at is a way to control the windows print spooler rather than the print job as the print job is already finished. Or is there a way to set an auto timeout to detele the document from the print queue with a windows setting or with java code?
2010-10-08 15:30:07
I'm not sure if there is an easy way to stop a specific job. It will probably involve using JNI, but I haven't coded enough windows specific stuff to tell you exactly how.However, if all you need is to *clear* the print queue, then you can possibly execute this using Runtime.getRuntime().exec() net stop spooler del C:\WINDOWS\system32\spool\PRINTERS\*.* /q net start spooler
kskjon
2010-10-11 07:41:32