views:

246

answers:

2

In Internet Cafes where people are allowed to print, sometimes they print more pages than they intended to.

I'm looking for a way to display an "Are you sure you want to print X pages?" dialog after they pressed print (in any application), but before the job is sent to the queue.

I'm looking for pointers on how to implement such a hook.

(I have considered modifying a FOSS PDF printer to first print into a PDF and then display the dialog and then if the user presses "Yes", print it on the real printer. But this seems a really roundabout way of doing this and one also loses printer-specific features this way.)

A: 

What os are you working with?

edk
Windows (but I would be interested in solutions for other OSs too)
Kalmi
+3  A: 

One of the things you could do which is also kind of round about, is pause the print spooler, print your job, get a page count, and then prompt the user for confirmation. If the user okays the job, then release the spooler. I don't have the API calls handy but I have manipulated spooler queues quite easily.

Of course the downside to this idea is if the queue is server-based and potential permission issues could be afoot.

Another alternative would be to force the output to a WMF or EMF file and tally the page count that way, then hand it off to the spooler. This is similar to your notion of outputting it to a PDF, but uses a native approach. (This is essentially what applications typically do(did) for doing previews-- rendering the job in a metafile format which is then displayed on screen or spooled to the printer)

Unfortunately there is no way to get the page count ahead of rendering the print job unless you are intimately aware of the contents and can judge it, so you are forced to at least go through the motions of printing.

Hope this helps.

Bill
I like the pause-the-spooler solution, thanks! Seems simple. Most of these printers are TCP/IP based, so each workstation has its own queue. The WMF/EMF solution seems cleaner, but I have no idea how to start there
Kalmi