Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculating length of printed string.
Message
 
To
17/01/2000 08:01:20
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00318779
Message ID:
00318923
Views:
21
Arne,

Fantastic! I knew there had to be a way since Windows (problably via the printer driver) is able to figure it out. My only regret is that it is a VB control which would mean that I would have to make sure that VB runtime in on the user's machine. No big deal if I was distributing my app via CD-ROM only but it is distributed over the Internet and it is already 7.5 MEGS. I guess that I could check for the runtime and, if is not on the user's machine, use plan B and/or have the user download the VB runtime as an Add-In module.

Thanks for the info.

Ed

>Edmond,
>
>I have been looking a bit into the Printer object in VB, which has a TextWidth-method which may be useful. From MSDN:
>
>object.TextWidth(string)
>Returns the width of a text string as it would be printed in the current font of a Form, PictureBox, or Printer.
>The width is expressed in terms of the ScaleMode property setting or Scale method coordinate system in effect for object. Use TextWidth to determine the amount of horizontal space required to display the text. If string contains embedded carriage returns, TextWidth returns the width of the longest line.

>
>Not much work wrapping it in an OCX.
>
>Arne
>
>
>>I have to be able to pad a string with asterisks so that, when it prints to a label, it will completely cover the length of the label.
>>
>>My question is, given an unknown printer, how do you convert the information from functions like FONTMETRIC() and TXTMETRIC() to calculate the length of a printed string?
>>
>>Let's say the font is Arial Normal 8 and FONTMETRIC(6), the average width, is 5 pixels. Leaving out TXTMETRIC() to make the example simple, let's say all of the characters in the string are "average".
>>
>>How many "average" characters do I need to cover a printed inch? Would this depend on the printer's dpi resolution and, if so, how do you determine the selected printer's resolution? I'm confused because a FONTMETRIC(6) return of 5 pixels doesn't go into my laser printer's 300 dpi and come out with a real number of characters per inch.
>>
>>Any help would be appreciated.
>>
>>Ed
Previous
Reply
Map
View

Click here to load this message in the networking platform