Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing--how many lines on a page?

Status
Not open for further replies.

dds82

Programmer
Jun 5, 2002
251
US
I'm trying to print something. How do I calculate the number of lines that fit on a page?

Thanks.
 
Assuming you have a device context for
the printer and that you've selected a
mapping mode and a font into it:

1. Get the physical length of the page:

int iHorzRes = pDC->GetDeviceCaps(HORZSIZE);

2. Convert the resolution into the map mode
(This app uses MM_LOENGLISH, so the conversion
is to 100ths of an inch):

iHorzRes = int(( float(iHorzRes) / 25.4f ) * float(100));

3. Get the height of the currently selected font:

TEXTMETRIC tm;
pDC->GetTextMetrics(&tm);
int iCharHt = abs(tm.tmHeight);

4. The number of lines is the horizontal length
divided by the character height.

JLC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top