Click or drag to resize

Printer Class

X#
Create an object that represents a single print job.
Inheritance Hierarchy
Object
  VObject
    EventContext
      Window
        Printer

Namespace:  VO
Assembly:  VOGUIClasses (in VOGUIClasses.dll) Version: 2.24 GA
Syntax
 CLASS Printer INHERIT Window
Request Example View Source

The Printer type exposes the following members.

Constructors
  NameDescription
Public methodPrinter
Construct a printer job.
Top
Methods
  NameDescription
Public methodCode exampleAbort
Instruct the printer to abort the current print job.
Public methodDestroy
Provide a method to de-instantiate a Printer object.
(Overrides Destroy.)
Public methodHandle
Return the handle for a printer.
Public methodIdle
Instruct the system to process events while printing.
Public methodIsValid
Determine if a printer is valid.
Public methodNewPage
Direct the attached printer to eject to a new page.
Public methodPrinterError
Called if a printer error occurs. PrintErrorEvent is interrogated to identify the type of error has occurred.
Public methodPrinterExpose
Invoked for each page (or part of a page) of the print job whenever it needs repainting.
Public methodStart
Start a print job or contiguous portion of a print job.
Top
Fields
  NameDescription
Public fieldlprAbort
Top
Remarks
It is essential to check the validity of a Printer object—using Printer:IsValid()—before using it. To use a printer, the application should call Printer:Start(), which repeatedly calls Printer:PrinterExpose() for each page printed until the final page, in which it returns FALSE. Printer:Start() returns when the print job is finished. You can also: Determine the size of the page using Window:CanvasArea and Window:WindowArea to return the size of the printable area and total page size, respectively Scale the printout using Window:Size Determine the origin using Window:Origin (for example, to create margins) X# will only print the correct font if it exists for your printer; otherwise, the font that is most similar is used. Printing is done in printer coordinates, which are device dependent. Use the methods described here to scale and size your printout. Also note that for business printing, such as management reports, invoices, and notification letters, it is usually more convenient to design a report with the Report Editor and then run the report using the ReportQueue class. For more information, refer to the Programmer's Guide.
Examples
The following example prints the text "Hello World":
X#
 1METHOD PrinterExpose(oPEE) CLASS PrinterClass
 2SELF:TextPrint("Hello World",Point{30,30})
 3RETURN FALSE            // Nothing more to print
 4CLASS PrinterClass INHERIT Printer
 5METHOD Init() CLASS PrinterClass
 6SUPER:Init()
 7RETURN SELF
 8METHOD MenuCommand(oMCE) CLASS StandardShellWindow
 9LOCAL oPrinter AS PrinterClass
10IF(oMCE:ItemID = ;
11IDM_EMPTYSHELLMENU_FILE_PRINT_ID)
12// File Print menu item ID
13oPrinter := PrinterClass{}
14IF(oPrinter:IsValid())
15oPrinter:Start()
16oPrinter:Destroy()
17ENDIF
18ENDIF
See Also

Reference