Printing/Previewing Text 
Author Message
 Printing/Previewing Text

I have a program that prints and previews (with a VB
PictureBox control) forms that have text, lines, etc.  I
have noticed that with long text strings (>50 characters),
the previewed output displays longer than the printed
output.  I even tested this in code by setting the font
properties on both the picturebox and printer objects to
the same typeface (Arial), size, weight, etc.  When I do a
GetTextExtentPoint32 on the same string, once using the
printer's hdc, and once using the picturebox's hdc, the cx
property from the SIZE variables are significantly
different for long strings.  The printer's resolution is
set to 600DPI, and the screen is set to 96DPI, so I am
multiplying the screen's text extent by (600/96 = 6.25).  
The values generally are pretty close, except when the
length of the string gets larger, which is when the text
extent on the screen gets significantly larger than that
on the printout. Why is this happening, and what can I do
to remedy it?  I am always using Arial as the typeface
which is a "TrueType" font which should provide WYSIWYG
functionality, correct?


Sun, 20 Feb 2005 04:12:13 GMT  
 Printing/Previewing Text
This is because of rounding problems in the font size between a high
resolution device (printer) and a low resolution (screen). When the string
is long, the difference is accumulated and the result is significant. In
fact you dont have WYSIWYG.

Maybe there are other solutions, but I solved it as follows: Always
calculate the size of a string in the high resolution device (printer), or
use a hidden DC and say 600dpi if there is no printer.

When you want to print the string in the low resolution device (screen),
print it character by character (in a loop), and calculate the position of
each character in the high resolution device. In this way, the error will
not be accumulated, and I think this is as close to WYSIWYG. as possible.

You can see the same effect in Microsoft Word. Try to type a string with a
continuous line, like this "________________", or underline a long string
and watch the line in print preview mode. Its possible that the line (which
should be continuous) seems that it is discontinued in certain points, by 1
pixel.

HTH,
Aris


Quote:
> I have a program that prints and previews (with a VB
> PictureBox control) forms that have text, lines, etc.  I
> have noticed that with long text strings (>50 characters),
> the previewed output displays longer than the printed
> output.  I even tested this in code by setting the font
> properties on both the picturebox and printer objects to
> the same typeface (Arial), size, weight, etc.  When I do a
> GetTextExtentPoint32 on the same string, once using the
> printer's hdc, and once using the picturebox's hdc, the cx
> property from the SIZE variables are significantly
> different for long strings.  The printer's resolution is
> set to 600DPI, and the screen is set to 96DPI, so I am
> multiplying the screen's text extent by (600/96 = 6.25).
> The values generally are pretty close, except when the
> length of the string gets larger, which is when the text
> extent on the screen gets significantly larger than that
> on the printout. Why is this happening, and what can I do
> to remedy it?  I am always using Arial as the typeface
> which is a "TrueType" font which should provide WYSIWYG
> functionality, correct?



Mon, 21 Feb 2005 06:39:51 GMT  
 Printing/Previewing Text
Cool, I wasn't sure I was going to get a response to
this, let alone a solution.  I will sure try this.  
Thanks a bunch!

Quote:
>-----Original Message-----
>This is because of rounding problems in the font size
between a high
>resolution device (printer) and a low resolution

(screen). When the string
Quote:
>is long, the difference is accumulated and the result is
significant. In
>fact you dont have WYSIWYG.

>Maybe there are other solutions, but I solved it as
follows: Always
>calculate the size of a string in the high resolution

device (printer), or
Quote:
>use a hidden DC and say 600dpi if there is no printer.

>When you want to print the string in the low resolution
device (screen),
>print it character by character (in a loop), and

calculate the position of
Quote:
>each character in the high resolution device. In this
way, the error will
>not be accumulated, and I think this is as close to

WYSIWYG. as possible.
Quote:

>You can see the same effect in Microsoft Word. Try to

type a string with a
Quote:
>continuous line, like this "________________", or

underline a long string
Quote:
>and watch the line in print preview mode. Its possible

that the line (which
Quote:
>should be continuous) seems that it is discontinued in

certain points, by 1
Quote:
>pixel.

>HTH,
>Aris



>> I have a program that prints and previews (with a VB
>> PictureBox control) forms that have text, lines, etc.  
I
>> have noticed that with long text strings (>50
characters),
>> the previewed output displays longer than the printed
>> output.  I even tested this in code by setting the font
>> properties on both the picturebox and printer objects
to
>> the same typeface (Arial), size, weight, etc.  When I
do a
>> GetTextExtentPoint32 on the same string, once using the
>> printer's hdc, and once using the picturebox's hdc,
the cx
>> property from the SIZE variables are significantly
>> different for long strings.  The printer's resolution
is
>> set to 600DPI, and the screen is set to 96DPI, so I am
>> multiplying the screen's text extent by (600/96 =
6.25).
>> The values generally are pretty close, except when the
>> length of the string gets larger, which is when the
text
>> extent on the screen gets significantly larger than
that
>> on the printout. Why is this happening, and what can I
do
>> to remedy it?  I am always using Arial as the typeface
>> which is a "TrueType" font which should provide WYSIWYG
>> functionality, correct?

>.



Mon, 21 Feb 2005 07:39:55 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ActiveX ScaleX Text Output Print Preview

2. Print preview of Rich text box contents

3. Edit Text on Print Preview

4. ActiveX ScaleX Text Output Print Preview

5. Print Dialog & Print Preview

6. Stripping out borders in Print Preview, Print

7. blank print preview and printing

8. Print preview triggering the standard print dialogue

9. Print preview works but printing does not

10. Print Margins different in Preview and Print

11. Print Preview/Print

12. Print Preview Print Button

 

 
Powered by phpBB® Forum Software