#Printer Positioning
14-Oct-91 23:20:56
Sb: #3063-#Printer Positioning
Fm: Dennis L. Harrington 76216,3472
To: john kesler 76012,1403
John,
There's also another very good reason to use GetDeviceCaps to determine
the printable page size. If you know the actual printable page length, it's
then easy to adjust your printing to any length paper. Compute the number
of verticle twips on the page and subtract whatever you want for top and
bottom margins and 1 line of text. Then just print from some form of loop
and increment the CurrentY yourself by the number of verticle twips
required for each line. Each time you increment the CurrentY, test the new
value against the maximum computed above. If the new CurrentY is greater
than the maximum, you've filled the page and it's time to start a new page.
This is especially handy with laser printers may be use either letter or
legal size paper.
Another really nice API function for printing is SetTextAlign. By
default, windows aligns text characters based on the top of each
character's cell. If you use only one font in a document, that's fine. But
if you want to use several fonts, this can result in some funny looking
typography because their base lines don't lineup, even if they're the same
point size. By resetting the text alignment to TA_BASELINE which aligns
characters on their typographical baselines, you can now mix different
fonts and different sizes and they line up correctly. If you do this, just
remember that with base aligned text, CurrentY is the text baseline and not
the top of the character cell. Printing the first line with CurrentY = 0
will only print the descenders of text characters on that line.
–dennis
There is 1 Reply.