ComponentOne VSView 8.0
Using the VSPrinter Control

The VSPrintercontrol makes it easy to create documents and reports for printing and print previewing from your applications. It only takes one statement to print plain text or RTF files, and a little more work to print graphics, tables, and formatted text. You have complete control over the printing device and document layout, including paper size and orientation, number of columns, headers and footers, page borders, shading, fonts, and so on.

The diagram below shows the basic sequence of steps required to create a VSPrinterdocument:

As the diagram shows, there are six main steps to using the VSPrintercontrol.

  1. Set up the Output Device:

    Here you define what kind of output you want to create. There are three main options.

    • Print Preview: Set the Preview property to True. If you want to use a specific printer (as opposed to the default printer), set the Device property to the name of the printer you want to use. This option generates the document in memory. When the document is finished, it can be previewed, saved to disk or sent to the printer.

    • Direct Printer Output: Set the Preview property to False. If you want to use a specific printer, set the Device property to the name of the printer you want to use. To allow the user to select a printer, use the PrintDialog method.

      This option sends all output directly to the printer, and there's no preview (the control remains blank.)

    • ExportFile (RTF or HTML): Set the Preview property to True, set the ExportFile and ExportFormat properties to the name and type of file you want to create. The file name should include the path and extension. The format may be RTF, plain HTML, DHTML, or paged HTML (multiple hyperlinked files).

      This option generates a regular preview document, and also an RTF or HTMLoutput file that can be viewed and edited with other software such as word processors and Web browsers.

      For a complete list of properties related to this step, see the Device Control and User Interface property groups below.

  2. Set up the Document:

    Here you define the document layout properties. VSPrinter provides reasonable defaults for these properties, but you may want to customize some of them. Typically, you will set the Font, MarginLeft, MarginTop, MarginRight, MarginBottom, Header and Footer properties.

    For a complete list of properties related to this step, see the Document Layout property group below.

  3. Start the document:

    Use the StartDoc method to start creating the document.

  4. Create the document:

    This is the main part of the process. Here you will use the Paragraph, AddTable, and other properties and methods that generate the document contents. When generating long documents, you should check the Error property periodically. If an error is detected while the document is being generated, you can exit any long loops you may have and cancel the document.

    For a complete list of properties related to this step, see the Output Generation property group below.

  5. End the Document:

    Use the EndDoc method to finish creating the document.

  6. Save/Print/PreviewDocument:

    At this point, if the document was created with the Preview property set to True, it is ready to be previewed, saved to disk, or sent to the printer.

    For a complete list of properties related to this step, see the User Interface and Document Management property groups below.

See Also

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback