IDLgrPrinter

Superclasses | Creation | Properties | Methods | Examples | Version History

A printer object represents a hardcopy graphics destination. When a printer object is created, the printer device to which it refers is the default system printer. To change the printer, utilize the printer dialogs (see DIALOG_PRINTJOB and DIALOG_PRINTERSETUP.)

Note
Objects or subclasses of this type can not be saved or restored.

Superclasses

None

Creation

See IDLgrPrinter::Init.

Properties

Objects of this class have the following properties. See IDLgrPrinter Properties for details on individual properties.

In addition, objects of this class inherit the properties of all superclasses of this class.

Methods

This class has the following methods:

In addition, this class inherits the methods of its superclasses (if any).

Examples

See Displaying, Copying and Printing Objects (Object Programming) for information on the IDLgrPrinter object. See Positioning Objects Within a Page (Object Programming) for additional examples that define the locations of objects within the hardcopy page.

The following example demonstrates the process of printing the contents of an IDL graphics display object (a buffer or a window) to an IDLgrPrinter object. The resolution of the printed page is based on the resolution of the screen. The model object in the printer object must be scaled to maintain the same size as displayed on the screen. The location of the view must also be changed to center the display on the page.

PRO PrintingAnImage 
 
; Determine the path to the "convec.dat" file. 
convecFile = FILEPATH('convec.dat', $ 
   SUBDIRECTORY = ['examples', 'data']) 
 
; Initialize the parameters of the image with the file. 
convecSize = [248, 248] 
convecImage = BYTARR(convecSize[0], convecSize[1]) 
 
; Open the file, read in the image, and then close the 
; file. 
OPENR, unit, convecFile, /GET_LUN 
READU, unit, convecImage 
FREE_LUN, unit 
 
; Initialize the display objects. 
windowSize = convecSize 
oWindow = OBJ_NEW('IDLgrWindow', RETAIN = 2, $ 
   DIMENSIONS = windowSize, $ 
   TITLE = 'Earth Mantle Convection') 
oView = OBJ_NEW('IDLgrView', $ 
   VIEWPLANE_RECT = [0., 0., windowSize]) 
oModel = OBJ_NEW('IDLgrModel') 
 
; Initialize the image object with its palette. 
oPalette = OBJ_NEW('IDLgrPalette') 
oPalette->LOADCT, 27 
oImage = OBJ_NEW('IDLgrImage', convecImage, $ 
   PALETTE = oPalette) 
 
; Add image to model, which is added to the view, and 
; then the view is displayed in the window. 
oModel->Add, oImage 
oView->Add, oModel 
oWindow->Draw, oView 
 
; Determine the centimeter measurements of the image 
; on the screen. 
oWindow->GetProperty, RESOLUTION = screenResolution 
windowSizeCM = windowSize*screenResolution 
 
; Initialize printer destination object. 
oPrinter = OBJ_NEW('IDLgrPrinter', PRINT_QUALITY = 2, $ 
   QUALITY = 2) 
 
; Obtain page parameters to determine the page 
; size in centimeters. 
oPrinter->GetProperty, DIMENSIONS = pageSize, $ 
   RESOLUTION = pageResolution 
pageSizeCM = pageSize*pageResolution 
 
; Calculate a ratio between screen size and page size. 
pageScale = windowSizeCM/pageSizeCM 
 
; Use ratio to scale the model within the printer to the 
; same size as the model on the screen. 
oModel->Scale, pageScale[0], pageScale[1], 1. 
 
; Determine the center of the page and the image in 
; pixels. 
centering = ((pageSizeCM - windowSizeCM)/2.) $ 
   /pageResolution 
 
; Move the view to center the image. 
oView->SetProperty, LOCATION = centering 
 
; Display the view within the printer destination. 
oPrinter->Draw, oView 
oPrinter->NewDocument 
 
; Cleanup object references. 
OBJ_DESTROY, [oPrinter, oView, oPalette] 
 
END 

Version History

5.0

Introduced

6.2

Added QueryRequiredTiles method

Added PRINTER_NAME property and revised NAME property