Home > Archive > Visual Basic > October 2004 > Printing in VB6
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Jonathan 2004-10-27, 3:55 pm |
| I have a few questions about printing in VB 6.
1) How do I determine how many lines of a font will fit on a page?
Obviously, there will be less lines of 24 font on a page than 12 font. It
would also depend on the font type and letter. An i is not as wide as a w.
Are there any methods for calculating this or is it just trial and error?
2) How can I add a picutre to the page to print? I have a few bitmaps and
gif's that I would like to add.
3) Is there a way to preview what I am about to print? I can easily waste a
lot of papper.
4) Can I set the font of one line to be bold and 16 and the next line to be
12 and regular font? Before I was setting the font with Printer.Fontbold =
true. Then I changed it to Printer.Fontbold = false. The whole document was
not bold - I wanted the first part to be bold. Can sections of the page have
different fonts in VB6? Or was I doing something wrong?
Thanks for the help.
| |
| Ken Halter 2004-10-27, 3:55 pm |
| Jonathan wrote:
> I have a few questions about printing in VB 6.
>
> 1) How do I determine how many lines of a font will fit on a page?
> Obviously, there will be less lines of 24 font on a page than 12 font. It
> would also depend on the font type and letter. An i is not as wide as a w.
> Are there any methods for calculating this or is it just trial and error?
To measure a single line, you can use the printer's TextHeight method.
> 2) How can I add a picutre to the page to print? I have a few bitmaps and
> gif's that I would like to add.
No experience... but see the 'HOWTO' article below.
> 3) Is there a way to preview what I am about to print? I can easily waste a
> lot of papper.
There are a whole bunch of Print Preview components on
planetsourcecode.com ..
> 4) Can I set the font of one line to be bold and 16 and the next line to be
> 12 and regular font? Before I was setting the font with Printer.Fontbold =
> true. Then I changed it to Printer.Fontbold = false. The whole document was
> not bold - I wanted the first part to be bold. Can sections of the page have
> different fonts in VB6? Or was I doing something wrong?
We use some of this code for printing. Basically, write the text to a
RichTextBox (multi font support built in) and then dump that box to the
printer.
HOWTO: Set Up the RichTextBox Control for WYSIWYG Printing
http://support.microsoft.com/defaul...kb;en-us;146022
> Thanks for the help.
--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
Please keep all discussions in the groups..
| |
| Larry Serflaten 2004-10-27, 3:55 pm |
|
"Jonathan" <Jonathan@discussions.microsoft.com> wrote
> I have a few questions about printing in VB 6.
>
> 1) How do I determine how many lines of a font will fit on a page?
> Obviously, there will be less lines of 24 font on a page than 12 font. It
> would also depend on the font type and letter. An i is not as wide as a w.
> Are there any methods for calculating this or is it just trial and error?
Set up the device with the correct font, and use its TextWidth and TextHeight
properties to measure various strings. While width can vary in a non-proportional
font, the height usually does not, so getting the total lines should be a simple
calculation, dividing the ScaleHeight of the device, by the TextHeight of a line.
> 2) How can I add a picutre to the page to print? I have a few bitmaps and
> gif's that I would like to add.
The printer supports the PaintPicture method.
> 3) Is there a way to preview what I am about to print? I can easily waste a
> lot of papper.
How about directing your printing to a picturebox first?
>
> 4) Can I set the font of one line to be bold and 16 and the next line to be
> 12 and regular font? Before I was setting the font with Printer.Fontbold =
> true. Then I changed it to Printer.Fontbold = false. The whole document was
> not bold - I wanted the first part to be bold. Can sections of the page have
> different fonts in VB6? Or was I doing something wrong?
The Print command should reflect whatever the current settings are.
Although its an iterative process: Print/change/print/change/print ... etc...
LFS
| |
| Lee Peedin 2004-10-27, 3:55 pm |
| I "fooled around" a lot with creating a "print-preview" and finally
just gave up and print to a PDFand look at the result. Lots of free
PDF drivers available (PDF995)
On Wed, 27 Oct 2004 11:53:26 -0500, "Larry Serflaten"
<serflaten@usinternet.com> wrote:
>
>"Jonathan" <Jonathan@discussions.microsoft.com> wrote
>
>Set up the device with the correct font, and use its TextWidth and TextHeight
>properties to measure various strings. While width can vary in a non-proportional
>font, the height usually does not, so getting the total lines should be a simple
>calculation, dividing the ScaleHeight of the device, by the TextHeight of a line.
>
>
>
>The printer supports the PaintPicture method.
>
>
>
>
>How about directing your printing to a picturebox first?
>
>
>
>The Print command should reflect whatever the current settings are.
>Although its an iterative process: Print/change/print/change/print ... etc...
>
>LFS
>
| |
| J French 2004-10-29, 8:55 am |
| On Wed, 27 Oct 2004 13:53:28 -0400, Lee Peedin
<lee@DONOTSPAMMEsafedatausa.com> wrote:
>I "fooled around" a lot with creating a "print-preview" and finally
>just gave up and print to a PDFand look at the result. Lots of free
>PDF drivers available (PDF995)
If you can write code to print to the Printer, then that code needs
very little modification to print to a Picturebox
|
|
|
|
|