printer under Win32

Geoffrey Gerrietts geoff at homegain.com
Mon Jun 25 23:09:19 CEST 2001


I think in some ways this is actually more a Windows GDI question than a
Python question, but I'm using the win32ui module so I'll ask it here (esp.
since I don't have ready access to any Windows-centric forums....)

The question is basically: what's the right way to determine page extents
when writing to a printer DC? Detail follows (if it matters):

I've managed to puzzle my way through font selection and font metrics, and
between web resources and the wonderful Python Programming on Win32 book
from ORA, I've managed to piece together a little program that prints a
plain-text file in a very nice format -- no UI on the thing, just 'feed it a
filename and it writes it to printer' -- it's a utility I've often wanted
for printing from Vim, among other excuses.

However, using raw TWIPS and calculating page length has resulted in some
(pretty big) page underruns. So I'm trying to figure out if there's a way to
actually ask the device context for its "printable area" boundaries, or at
least for its 'recognized on the page' boundaries.

In looking through the win32 docs on the ActiveState site (which reminds me
-- am I one of the only ones whose pythonwin reference docs were mauled in
the official distribution?) -- I spotted two likely candidates:
dc.GetViewportExt() or dc.GetWindowExt(), but I'm not sure what each does;
GetWindowExt() seems to provide more "reasonable" results, but I'm still
wondering....

Thanks,
--G.

---
Geoff Gerrietts <geoff at homegain.com>
Software Engineer, HomeGain.com
510-655-0800 x4320
 




More information about the Python-list mailing list