General printing tips and tricks, Printing a legend in your map, Printing a legend in your – Pitney Bowes MapXtreme User Manual

Page 526

Advertising
background image

Appendix E: Printing From MapXtreme Applications

General Printing Tips and Tricks

MapXtreme v7.1

533

Developer Guide

Using this method, you have access to the graphics object and can use any of the available graphics
routines to print extra graphics or text.

General Printing Tips and Tricks

L

MapInfo cannot, and does not, recommend one printer/plotter over another, nor verify that a
particular printer works 100 percent of the time. There are too many variables that affect the
output to be able to make a recommendation.

The following tips and suggestions come from our knowledgebase of specific common problems and
solutions our users have found while printing.

Good first steps in troubleshooting a printing problem are to make sure you have downloaded and
installed the patch for your release of MapXtreme, if any, and are using the latest printer driver for
your printer/operating system. Exceptions are noted in this document.

How to Overload a Print Page Event

Our .NET printing API provides a mechanism for overloading the print page event. This allows you to
add customizations to each printed page. For example, you could add a title, page number, logo, etc.

To do this, you need to implement a PrintPageEventHandler. Here's an example:

this.mapPrinting = new MapPrinting();
this.mapPrinting.Map = this.mapControl1.Map;
this.mapPrinting.PrintDocument.PrintPage += new
System.Drawing.Printing.PrintPageEventHandler(this.mapPrintDocument1_Prin
tPage);

private void mapPrintDocument1_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{

// TODO - add your code here to alter the printed page

}

Printing a Legend in Your Map

As mentioned at the beginning of this section, MapXtreme does not support the printing of layouts. If
you want to print a legend in your map, you need to add the legend as an adornment to your map.
Here is some sample code to demonstrate how this works:

//create cartographic legend
MapInfo.Mapping.Legends.Legend legend =
mapControl1.Map.Legends.CreateLegend(new System.Drawing.Size(5, 5));
legend.Border = true;
MapInfo.Mapping.LayerType[] normalLyr = new MapInfo.Mapping.LayerType[1];
normalLyr[0] = MapInfo.Mapping.LayerType.Normal;

Advertising