Print Preview ActiveX Active Users: 54 / Visits Today: 78
Highest Active Users: 54
Print Preview ActiveX
Home | Profile | Register | Active Topics | Members | Search | FAQ | RSS
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Print Preview
 Tips & Tricks
 VB Code Snippet: fit plain text in area
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic: VB Routine: paraTextList Topic Next Topic: VB Routine: getNumLines  

wbgookin
Junior Member

USA
113 Posts

Posted - 11/20/2004 :  02:50:19  Show Profile  Visit wbgookin's Homepage  Reply with Quote
My code fitting routine is too complicated to explain quickly (naturally it's not terribly well documented, but it will do horizontal or vertical text), but the basics of it are below. It uses the getNumLines I posted here to calculate the required number of lines, and then iterates, shrinking the font if necessary. Then to print this, you use similar code that is in the getNumLines to loop through each word and print it.



'Based on the width allowed, get the number of lines
numberOfLines = getNumLines(prn, printText, fitWidth)

'If numberOfLines*lineheight is greater than the allowed height, we need to start shrinking the font
initFontSize = prn.FontSize
delta = 0
Do While numberOfLines * prn.TextHeight("A") >= prnHeight And delta < initFontSize
    delta = delta + 1
    prn.FontSize = initFontSize - delta
Loop

'We also need to check the width, in case a single word is greater than the available width
'Set the initial X just in case
For i = LBound(splitText) To UBound(splitText)
    Do While prn.TextWidth(Trim(splitText(i) & splitString)) >= prnWidth And delta < initFontSize
        delta = delta + 1
        prn.FontSize = initFontSize - delta
    Loop
Next i
Go to Bottom of Page
  Previous Topic: VB Routine: paraTextList Topic Next Topic: VB Routine: getNumLines  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Print Preview ActiveX © Mandix Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000 Version 3.4.02