Printing and Exporting
- 4 minutes to read
The Map control makes it possible to print a map and export it to numerous file formats.
Make sure that your project references the DevExpress.Xpf.Printing.24.2 and DevExpress.Printing.v24.2.Core assemblies to be capable to perform the following tasks.
#Invoke the Print Preview Window
Use one of the following methods to invoke the Print Preview with a toolbar or the Print Preview with a Ribbon.
Method | Description |
---|---|
Map |
Invokes the Print Preview window, which shows the print preview of the Map control. |
Map |
Invokes the modal Print Preview window, which shows the print preview of the Map control. |
Map |
Invokes the Print Preview window with a Ribbon for the Map control. |
Map |
Invokes the Print Preview modal dialog with a Ribbon for the Map control. |
The code below shows how to invoke the Print Preview form with the Ribbon on the button click event.
private void onButtonClick(object sender, RoutedEventArgs e) {
mapControl.ShowRibbonPrintPreviewDialog(this);
}
#Print a Map
The Print Preview allows you to immediately print a map using default settings or to configure the required options before printing.
To print a map using the default printer and predefined settings, click Quick Print.
To change settings before printing, select the Print… item.
In the Print… dialog, configure settings and click OK to print a map.
#Export a Map
The Map control provides several ways to export a map.
To export a map to the desired file format from code, use one of the following methods.
Property Description Map Control. Export To Html Exports a map to an HTML file. Map Control. Export To Image Exports a map to an image. Map Control. Export To Mht Exports a map to an MHT file. Map Control. Export To Pdf Exports a map to a PDF file. Map Control. Export To Rtf Exports a map to an RTF file. Map Control. Export To Xls Exports a map to an XLS file. Map Control. Export To Xlsx Exports a map to an XLSX file. Map Control. Export To Xps Exports a map to an XPS file. Map Control. Export To Docx Exports a map to a DOCX file. The code below shows how to export a map to the specified PDF file on the button click event.
private void onButtonClick(object sender, RoutedEventArgs e) { mapControl.ExportToPdf("D://document.pdf"); }
In addition, you can export a map vector layer’s content to one of the supported formats using the following methods.
Method Description Vector Layer Base. Export To Kml Exports data from a vector layer using the KML file format. Vector Layer Base. Export To Svg Exports data from a vector layer using the SVG file format. Vector Layer Base. Export To Shp Exports vector layer data to the specified shapefile. Use the following code to export the map’s vector data to the specified KML file.
You can export a map using the Print Preview window. To do this, select the desired format in the Export item’s drop-down list.
In the Export Document… window, configure exporting options and click OK.
#Configure Map Print/Export Settings
It is possible to change the map’s print/export options, for instance, size mode. To do this, use the following markup.
<dxm:MapControl x:Name="mapControl">
<dxm:MapControl.PrintOptions>
<dxm:MapPrintOptions SizeMode="Zoom"
PrintMiniMap="False"/>
</dxm:MapControl.PrintOptions>
<!--...-->
</dxm:MapControl>
The code above uses the following classes and properties.
Class or Property | Description |
---|---|
Map |
Gets or sets print options of the Map control. |
Map |
Stores map print options. |
Map |
Specifies whether to print/export a mini map. |
Map |
Specifies a map size mode. To set this property, use items of the Map |