Class XbpPrinter() Foundation

Class function of the XbpPrinter class.


Objects of the XbpPrinter() class are used to output graphics that are created using functions of the GRA engine. To allow this, a printer driver (printer object) must be installed that controls the physical printer. If several printer drivers, or printer objects, respectively, are installed, the default printer can be set using the context menu of the printer object. For each installed printer object a separate XbpPrinter object can be created that is then used to perform output using the applicable print driver.

Generally print output is asynchronous in GUI applications. This means that data for the printer is stored in a file or "spooled". The actual task of printing is handled by the spooler. The spooler takes each print job and sends it to the printer as soon as it is ready to process. This means that the program does not need to wait until everything is printed, but can continue as soon as the print job is handed to the spooler. The spooler is automatically managed by the operating system.

Graphic output in an Xbase++ program is performed in a presentation space that must be linked with a device context (an output device). An XbpPrinter object represents the device context for a presentation space whose graphic output will be printed. To allow this, the name of a printer object installed on the desktop must be specified to the XbpPrinter object. This XbpPrinter object must also be linked with the presentation space where the graphic output occurs (see example).

The start of print output is signalled by the :startDoc() method of the XbpPrinter object. All subsequent calls to Gra...() functions in the print job are combined and spooled together. The end of the print output (more precisely: the end of spooling) is indicated using the :endDoc() method. Data from the spooler is sent on to the printer only after the :endDoc() method is executed.

Class methods
Creates an instance of the XbpPrinter class.
Returns a list with the names of all installed printer objects.
Instance variables
Contains the Comment property of a printer object.
Determines the name of the printer.
Additional parameters for certain printer drivers.
Contains the Port property of a printer object.
Determines the name of the printer driver.
Contains the Location property of a printer object.
The format of the spool file.
The default name assigned to a spool job.
Life cycle
Requests system resources for the printer device context.
This method has no effect in the XbpPrinter() class.
Releases system resources.
Device properties
Retrieves the handle of a printer's device context
Retrieves the forms selectable on the printer device.
Retrieves the paper bins installed in the printer device.
Returns the paper size in 1/10 millimeters.
Determine the current status of a printer.
Retrieves the resolutions supported by the current printer device.
Printer settings

All methods in this group should only be called before a XbpPrinter object is associated with a presentation space. Calling them after an XbpPresSpace object is associated with the device context requires to :configure() the presentation space.

Retrieves or sets the collation mode of the current printer device.
Sets or retrieves the mode for colored printing in color-capable printers.
Sets the system's default printer.
Sets or retrieves the mode for duplex printing
Retrieves or sets the font options for this printer.
Retrieves or sets the size of the output media.
Sets or retrieves the number of copies per print job.
Retrieves or sets the paper orientation for a printer.
Selects the bin to load the paper from.
Set file to print to.
Retrieves or sets the print resolution.
Activates a dialog that allows the user to select attributes for the print job.
Deletes output spooled since :startDoc().
Signals the end of graphic output (the end of a document).
Indicates a page break.
Indicates the beginning of a page.
Indicates that the current page has ended.
Signals the beginning of graphic output (the start of a document).
Printing an image

// This example demonstrates the basic process of 
// printing images. A presentation space is created 
// in the UDF PrinterPS() that is linked to a device 
// context for a printer. 

#include "" 
#include "" 


   // Create presentation space for default printer 
   oPS := PrinterPS() 

   // Activate spooling 

   // Spool graphic output 
   GraBox( oPS, {10,10}, {400,100} ) 
   GraStringAt( oPS, {20,50}, "Image is printed") 

   // End spooling 

   DestroyDevice( oPS ) 

// Create presentation space and link to 
// device context for printer. The coordinate 
// system unit is 1/10 millimeter. 
FUNCTION PrinterPS( cPrinterObjectName ) 
   LOCAL oPS, oDC := XbpPrinter():New() 
   LOCAL aSize 

   oDC:Create( cPrinterObjectName ) 

   oPS := XbpPresSpace():New() 
   aSize := oDC:paperSize() 

   // Size of printable region on paper 
   aSize := { aSize[5] - aSize[3], ; 
              aSize[6] - aSize[4]  } 
   oPS:Create( oDC, aSize, GRA_PU_LOMETRIC ) 

PROCEDURE DestroyDevice( oPS ) 
   LOCAL oDC := oPS:device() 

   IF oDC <> NIL 
Print text using different fonts

// In this example, the array aFontlist is filled with 
// all of the fonts that can be displayed on the screen. 
// All of these fonts that are device independent vector 
// fonts are then output to the printer. The type size is 
// incremented as fonts are printed. 

#include "" 

   LOCAL oWindowPS, oPrinterPS, oFont, aFontList 
   LOCAL i, imax, nY, nPointSize, cText, aSize 

   // Presentation space for window and printer 
   oWindowPS  := SetAppWindow():presSpace() 
   oPrinterPS := PrinterPS() 

   // Creat font object 
   oFont := XbpFont():new( oWindowPS ) 

   // Build list of available fonts 
   aFontList := oFont:list() 

   // Output fonts to printer 

   imax       := Len( aFontList ) 
   nY         := oPrinterPS:device():paperSize()[2] - 100 
   nPointSize := 1 
   FOR i:=1 TO imax 

      // Print only generic vector fonts 
      IF aFontList[i]:generic .AND. aFontList[i]:vector 

         oFont := aFontList[i] 
         oFont:nominalPointSize := ++nPointSize 

         // Set font for printer 
         GraSetFont( oPrinterPS, oFont ) 

         cText := Str( nPointSize, 2 ) + "." + ; 

         // Calculate size and new y position for string 
         aSize := GraQueryTextBox( oPrinterPS, cText ) 
         nY    := nY - aSize[1,2] 

         // Print string and release font 
         GraStringAt( oPrinterPS, {20,nY}, cText ) 



   LOCAL oPS, oDC := XbpPrinter():New() 
   LOCAL aSize 


   oPS   := XbpPresSpace():New() 
   aSize := oDC:paperSize() 

   // Size of printable region on paper 
   aSize := { aSize[5] - aSize[3], ; 
              aSize[6] - aSize[4]  } 
   oPS:Create( oDC, aSize , GRA_PU_LOMETRIC ) 

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.