Re:Help.. Printer resolutions using printer.BeginDoc
Quote
Ken Fletcher <KenFletc...@juno.com> wrote in message
news:388cab85@news.nwlink.com...
Quote
> With custom printouts using printer.Canvas.TextOut I am continually
fighting
> the printer resolution. What is an easy way of deriving the xy
coordinates
> for TextOut for the different resolutions (300, 600, 1200). The xy
> coordinates are in pixels for the TextOut call.
You can get the horizontal and vertical resolutions in pixels/inch (they can
be different, and certainly will be if you are printing to a fax renderer)
from the GetDeviceCaps API function.
GetDeviceCaps(Printer.Handle, LOGPIXELSX)
GetDeviceCaps(Printer.Handle, LOGPIXELSY)
My suggestion would be to write a few functions that convert from physical
page measurements in tenths-of-an-inch or millimetres into pixels. Then wrap
up Canvas.TextOut in a procedure that takes position parameters in
metric/imperial and handles the conversion.
Don't forget that the TextOut position is relative to the top-left corner of
the *printable* page, not the physical page, so you also need to take the
unprintable margins into account. GetDeviceCaps can help there too - just
pass it the PHYSICALOFFSETX and PHYSICALOFFSETY constants.
If you want to get tricky, you could use OffsetViewportOrgEx to offset the
page origin to the physical top-left corner, but you need to do this at the
start of every page.
--
Stephen Brown