views:

11

answers:

1

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)

http://www.exampledepot.com/egs/javax.print/Cancel.html

kskjon
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.
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?
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