[python-win32] StartDoc failed
Luc Saffre
luc.saffre at gmx.net
Sat Feb 19 15:21:18 CET 2005
Hello,
if my default windows printer is a network printer and not available,
then dc.StartDoc() causes a traceback which I cannot catch using
try...except. According to
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_CDC.3a3a.StartDoc.asp
I would have expected it to simply return 0 or negative on failure.
Example:
#file startjob.py
import win32ui
dc = win32ui.CreateDC()
dc.CreatePrinterDC(None)
try:
dc.StartDoc("foo")
# ... print to printer
dc.EndDoc()
except Exception,e:
print "your default printer is not reachable"
If I run this, I get:
Traceback (most recent call last):
File "startjob.py", line 6, in ?
dc.StartDoc("foo")
win32ui: StartDoc failed
Is there a workaround? How can I catch and handle the case of a
non-ready printer?
(i'm using pywin32 build 203 and python 2.3)
tia,
Luc
More information about the Python-win32
mailing list