Width Property (ExportFormat)
Gets or sets the number of pixels that represents the width of the output file.
public double Width {get; set;}
Public Property Width As Double
ExportBMP_ActiveMap
//This example demonstrates how to export the active mapview to BMP.
//Added references
using ArcGIS.Desktop.Framework.Threading.Tasks; //QueuedTask
using ArcGIS.Desktop.Mapping; //MapView and Export formats
public class ExportActiveMapToBMPExample
{
public static Task ExportActiveMapToBMPAsync(string Path)
{
return QueuedTask.Run(() =>
{
//Reference the active map view
MapView map = MapView.Active;
//Create BMP format with appropriate settings
BMPFormat BMP = new BMPFormat();
BMP.Resolution = 300;
BMP.Height = 500;
BMP.Width = 800;
BMP.HasWorldFile = true;
BMP.OutputFileName = Path;
//Export active map view
if (BMP.ValidateOutputFilePath())
{
map.Export(BMP);
}
});
}
}
ExportGIF_ActiveMap
//This example demonstrates how to export the active mapview to GIF.
//Added references
using ArcGIS.Desktop.Framework.Threading.Tasks; //QueuedTask
using ArcGIS.Desktop.Mapping; //MapView and Export formats
public class ExportActiveMapToGIFExample
{
public static Task ExportActiveMapToGIFAsync(string Path)
{
return QueuedTask.Run(() =>
{
//Reference the active map view
MapView mapv = MapView.Active;
//Create GIF format with appropriate settings
GIFFormat GIF = new GIFFormat();
GIF.Resolution = 300;
GIF.Height = 500;
GIF.Width = 800;
GIF.HasWorldFile = true;
GIF.OutputFileName = Path;
//Export active map view
if (GIF.ValidateOutputFilePath())
{
mapv.Export(GIF);
}
});
}
}
Export a map frame to JPG
//Export a map frame to JPG.
//Create JPEG format with appropriate settings
//BMP, EMF, EPS, GIF, PDF, PNG, SVG, TGA, and TFF formats are also available for export
//at 2.x - JPEGFormat JPG = new JPEGFormat()
//{
// HasWorldFile = true,
// Resolution = 300,
// OutputFileName = filePath,
// JPEGColorMode = JPEGColorMode.TwentyFourBitTrueColor,
// Height = 800,
// Width = 1200
//};
JPEGFormat JPG = new JPEGFormat()
{
HasWorldFile = true,
Resolution = 300,
OutputFileName = filePath,
ColorMode = JPEGColorMode.TwentyFourBitTrueColor,
Height = 800,
Width = 1200
};
//Reference the map frame
MapFrame mf = layout.FindElement("MyMapFrame") as MapFrame;
//Export on the worker thread
await QueuedTask.Run(() =>
{
//Check to see if the path is valid and export
if (JPG.ValidateOutputFilePath())
{
mf.Export(JPG); //Export the map frame to JPG
}
});
Export the map view associated with a map frame to BMP
//Export the map view associated with a map frame to BMP.
//Create BMP format with appropriate settings
//EMF, EPS, GIF, JPEG, PDF, PNG, SVG, TGA, and TFF formats are also available for export
BMPFormat BMP = new BMPFormat()
{
Resolution = 300,
Height = 500,
Width = 800,
HasWorldFile = true,
OutputFileName = filePath
};
//Reference the active layout view
LayoutView lytView = LayoutView.Active;
//Reference the map frame and its map view
MapFrame mf_bmp = layout.FindElement("Map Frame") as MapFrame;
//Export on the worker thread
await QueuedTask.Run(() =>
{
MapView mv_bmp = mf_bmp.GetMapView(lytView);
if (mv_bmp != null) {
//Check to see if the path is valid and export
if (BMP.ValidateOutputFilePath())
{
mv_bmp.Export(BMP); //Export to BMP
}
}
});
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.