Advanced Printing

Although the options which the PrintDoc method offers are sufficient for most applications, there are situations where you may need more control over the printing process. You may, for instance, want to select a different paper bin for the first and the following pages. This is where the PrintPage method is used.

In order to give you maximum flexibility, all that PrintPage does is to send a single page to the printer. It does not even eject the printed page, so that it can be used to print the contents of multiple Text Controls on a single sheet of paper.

PrintPage only has a single parameter, which is the page number, and you need to call it for every page to be printed in turn. Some additional methods and properties are required to select a printer and to control the print job, as shown in this code snippet:

[Visual Basic 6]
For CurPage = 1 To TXTextControl1.CurrentPages
   ' Initialize the VB Printer object
   ' Select a printer
   TXTextControl1.PrintDevice = Printer.hDC
   ' Print one page
   TXTextControl1.PrintPage CurPage
   ' Eject the page
   If CurPage <> EndPage Then Printer.NewPage
Next CurPage
' Tell Print Manager we are finished

The following examples will show you how to extend this basic printing routine with additional features.