Re: Printing in VB6

From: Ken Halter (Ken_Halter_at_Use_Sparingly_Hotmail.com)
Date: 10/27/04


Date: Wed, 27 Oct 2004 09:39:12 -0700

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/default.aspx?scid=kb;en-us;146022

> Thanks for the help.

-- 
Ken Halter - MS-MVP-VB - http://www.vbsight.com
Please keep all discussions in the groups..


Relevant Pages

  • Re: VB Printer Dialog Problem (VB6)
    ... What I would really like to know is exactly what it is you are printing? ... Forms and printers have very different resolutions (typically 96 pixels per inch in the case of a Form and 600 pixels per inch in the case of a printer). ... Font sizes can only be in "whole pixel values", so when you ask for an 11 point font on a specific device the operating system will examine the "pixels per inch" of that device and will give you the nearest font size it can, to the nearest whole pixel value. ... If you are using a RichTextBox then it is very easy to do that. ...
    (comp.lang.basic.visual.misc)
  • Re: Site critique requested (mostly accessibility issues, but anything else welcome)
    ... serif font. ... , and for printing. ... The reader then has the choice of not printing the ... Culpeper is largely maintained by volunteers ...
    (uk.net.web.authoring)
  • Puzzles with printed output
    ... I'm working with printing from a subclass of JTextPane. ... but I had similar problems with Swing's built-in Serif font. ... same as in printed output from Word), but it appears to be bold, although I ... Line spacing on the screen is the same as in Word (with Word's line spacing ...
    (comp.lang.java.gui)
  • Re: Data Report: Do it the hard way :-)
    ... I've never seen that code before so I don't yet know for certain exactly how it works but I've just downloaded it now for a quick look and it seems to be using the more or less standard simple print preview technique of passing a DC to a main printing routine and using more or less the same code to set up the font and graphic settings of the DC and then sending text and images to it. ... You can see the effects of this problem straight away if you download the code from the link you posted and run the PrintPreviewDemo_BMP example and click the Print Preview Instructions button and perform both a Preview and a Print to the printer. ...
    (microsoft.public.vb.general.discussion)
  • RE: I CANNOT PRINT ANY NEWLY CREATED WOR/ EXCEL DOCS, BLANKS COMIN
    ... I have just realised my printing Word problem, ... created two wks I chose navy as the font colour, and I have just changed my ... I still think its weird that my black emails and BBC weather web page has ... I DID EMAIL MY NEW LETTERS TO A MATE AND SHE COULD PRINT OFF MY NEW WORD ...
    (microsoft.public.word.docmanagement)