The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



CopyToOpenPrinter


Unit:SDL_geomap
Class: TGeoMap
Declaration: [1] procedure CopyToOpenPrinter (var x,y: integer; ScaleF: double);
[2] procedure CopyToOpenPrinter (MapWindow: TRect; Scale: integer; PosHoriz, PosVert: integer);
[3] procedure CopyToOpenPrinter (TopLeft: TPoint; Scale: integer; PosHoriz, PosVert, Width, Height: integer);

The method CopyToOpenPrinter is a more flexible alternative to the method PrintIt. It provides a way to create a graphical output on the currently selected printer. You may change the selected printer by assigning a proper value to the PrinterIndex property of the Printer object before calling CopyToOpenPrinter. In contrast to PrintIt, the user has to take care by himself that the printer object is already open for receiving data. This can be accomplished either by the method Printer.BeginDoc (see Delphi manual for details), or by assigning the printer output to a text file (Delphi procedureAssignPrn).

CopyToOpenPrinter is available in three overloaded versions which perform differently:

  • version [1] prints the visible portion of the map using a relative magnification factor
  • version [2] prints a specific area of the map using an exact scale
  • version [3] prints a part of the map having a specific width and height in the print at a given scale

Version [1]:

The variable parameters x and y contain the coordinates of the upper left corner of the map in printer coordinates on entry of the routine, and return the printer coordinates of the lower right corner of the map after the method is finished. This feature can be used to combine several hardcopies on one page, since the x- and y-values after a first hardcopy can be partly used as inputs of the next hardcopy.

The parameter ScaleF determines the magnification factor of the printout. A factor of 1.0 creates an output which has roughly the size of the screen image (assuming a monitor resolution of 80 dots per inch).

Version [2]:

This version defines the area of the printed map by specifying the area within in the map image. The parameter MapWindow specifies the area of the map (in pixel coordinates of the map image) to be printed. The parameter Scale defines the scale of the printed map (1:Scale). The parameters PosHoriz and PosVert determine the position of the upper left corner of the printed map on the paper (in mm).

Version [3]:

This version defines the area of the printed map by specifying the area in the printout. The parameter TopLeft specifies the top left corner of the map in map coordinates (pixels). The parameter Scale defines the scale of the printed map (1:Scale). The parameters PosHoriz and PosVert determine the position of the upper left corner of the printed map on the paper (in mm). The parameters Width and Height determine the width and height of the printed map area in mm.

Hint 1: Please note that the versions [2] and [3] print the entire map (or specified parts of it) while the version [1] always prints only the visible portion of the map.

Example: The following code snippet shows a short example how to mix several graphics and some text on one printer page.
 
  Printer.Title := 'Test';
  Printer.BeginDoc;
  Printer.Canvas.TextOut (300,180,'This is some text');
  Printer.Canvas.TextOut (300,240,'Another text line');
  x := 100;
  y := 320;
  GeoMap1.CopyToOpenPrinter (x,y, 0.8);   { the first map }
  Printer.Canvas.TextOut (300,y+20,'Yet another line of text');
  x := 300;
  y := y+120;
  GeoMap2.CopyToOpenPrinter (x,y, 0.4);  { the second map }
  Printer.EndDoc;

Hint 2: When printing to Adobe Distiller, release 7.0 or later, you have to specify the property Title of the printer (Printer.Title = 'Any Title'), otherwise the Adobe printer driver will crash.



Last Update: 2012-Oct-24