tags:

views:

268

answers:

2

I have a rather unusual problem. I am using xpdfprint binary for the print job from my application. But if the user has a "directly print to the printer" setting enabled and by mistake if the printer is not available (power failure or cord not plugged in) then the application hangs. It seems to be a standard behaviour since in my machine other windows applications also behave the same way. Problem is, in this case the printer timeout is not happening, neither it returns an error. It is waiting on the synchronous call to finish the printing. Is there anyway I can handle this situation? I am forced to find a solution because of a demanding customer. If by some means I get the physical printer status before the printing job is sent, I could solve this problem to an extent. Mine is a windows application and the coding is largely done in C#. If anybody has a win32 sample code please share with me.

Thanks in advance for any kind of help.

A: 

If the printer isn't connected then don't have a print menu item enabled, with a message.

Then, you just check every so often on the status.

You may find this of interest to check the status: http://www.codeproject.com/KB/printing/printeroffline.aspx

James Black
Thanks James for the help. Is there a way in which I could time out the printer job programmatically?
bobs
What do you mean time it out? If the job doesn't finish in some time then cancel it?
James Black
A: 

Your probably hung in StartDoc. This can be easily verified in the debugger. I'm guessing that your application does not have an abort proc set. Petzold has a good explanation and sample code (Petzold, Cancelling printing with an abort procedure).

ReedB