Code Comments
Programming Forum and web based access to our favorite programming groups.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.
Post Follow-up to this messageJonathan 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 b e > 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 wa s > not bold - I wanted the first part to be bold. Can sections of the page ha ve > 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..
Post Follow-up to this message"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 TextHeigh t properties to measure various strings. While width can vary in a non-propor tional font, the height usually does not, so getting the total lines should be a si mple 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 b e > 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 wa s > not bold - I wanted the first part to be bold. Can sections of the page ha ve > 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
Post Follow-up to this messageI "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 TextHeig ht >properties to measure various strings. While width can vary in a non-propo rtional >font, the height usually does not, so getting the total lines should be a s imple >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 >
Post Follow-up to this messageOn 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
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.