Pitney Bowes MapXtreme User Manual

Page 525

Advertising
background image

Appendix E: Printing From MapXtreme Applications

Implementing Printing in Your Application

MapXtreme v7.1

532

Developer Guide

this.mapPrinting.PageSettingsDialog();

You have access to the printer settings through the print document, which is part of the main printing
class. Because we add setting and options to our derived class that support our mapping needs, you
must get the class off the map printing object and re-cast it to our derived class.

mapPrinting = new MapPrinting();
mapPrinting.Map = mapControl1.Map;
MapPrintDocument mapPrintDocument = mapPrinting.PrintDocument

as MapPrintDocument;

if (mapPrintDocument != null) {

// here are some examples of how to set print options
// Set these based on your needs
mapPrintDocument.DrawingAttributes.SpecialTransparentRasterHandling

= true;

mapPrintDocument.PrintMethod = PrintMethod.Direct;
// and set other properties of mapPrintDocument

}

We do not provide any UI for changing our map print options. The dialogs allow the user to change
system printer settings only. If you want to provide the user with additional options, you'll must
provide your own UI to set the properties on MapPrintDocument (such as DrawingAttributes and
PrintMethod and PrintSize).

The print document is also where you gain access to the print process and where you add callbacks
when printing events occur. For example, you may want to add a logo or other graphics to each
printed page.

C# example

mapPrinting = new MapPrinting();
mapPrinting.Map = mapControl1.Map;
mapPrinting.PrintDocument.PrintPage += new
PrintPageEventHandler(mapPrintDocument1_PrintPage);

private void mapPrintDocument1_PrintPage(object sender,
PrintPageEventArgs e)
{

// add customization for each page (ie; title, page #, etc.)
Graphics g = e.Graphics;

}

VB example

mapPrinting = New MapPrinting()
mapPrinting.Map = mapControl1.Map
AddHandler mapPrinting.PrintDocument.PrintPage, AddressOf
mapPrintDocument1_PrintPage

Private Sub mapPrintDocument1_PrintPage(ByVal sender As Object, ByVal e As
PrintPageEventArgs)
' add customization for each page (ie; title, page #, etc.)
Dim g As Graphics = e.Graphics
End Sub

Advertising