public class PNGFormat : ExportFormat
Public Class PNGFormat Inherits ExportFormat
public class PNGFormat : ExportFormat
Public Class PNGFormat Inherits ExportFormat
//This example demonstrates how to export a layout to PNG. //Added references using ArcGIS.Desktop.Core; //Project using ArcGIS.Desktop.Layouts; //Layout classes using ArcGIS.Desktop.Framework.Threading.Tasks; //QueuedTask using ArcGIS.Desktop.Mapping; //Export formats public class ExportLayoutToPNGExample { public static Task ExportLayoutToPNGAsync(string LayoutName, string Path) { //Reference a layoutitem in a project by name LayoutProjectItem layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals(LayoutName)); if (layoutItem == null) return Task.FromResult<Layout>(null); //Create PNG format with appropriate settings PNGFormat PNG = new PNGFormat(); PNG.Resolution = 300; PNG.OutputFileName = Path; return QueuedTask.Run(() => { //Export Layout Layout lyt = layoutItem.GetLayout(); //Loads and returns the layout associated with a LayoutItem if (PNG.ValidateOutputFilePath()) { lyt.Export(PNG); } }); } }
//This example demonstrates how to export an individual map frame on a layout to PNG. //Added references using ArcGIS.Desktop.Core; //Project using ArcGIS.Desktop.Layouts; //Layout classes using ArcGIS.Desktop.Framework.Threading.Tasks; //QueuedTask using ArcGIS.Desktop.Mapping; //Export formats public class ExportMapFrameToPNGExample { public static Task ExportMapFrameToPNGAsync(string LayoutName, string MFName, string Path) { //Reference a layoutitem in a project by name LayoutProjectItem layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals(LayoutName)); if (layoutItem == null) return Task.FromResult<Layout>(null); //Create PNG format with appropriate settings PNGFormat PNG = new PNGFormat(); PNG.Resolution = 300; PNG.OutputFileName = Path; return QueuedTask.Run(() => { //Export MapFrame Layout lyt = layoutItem.GetLayout(); //Loads and returns the layout associated with a LayoutItem MapFrame mf = lyt.FindElement(MFName) as MapFrame; PNG.OutputFileName = Path; if (PNG.ValidateOutputFilePath()) { mf.Export(PNG); } }); } }
//This example demonstrates how to export the active mapview to PNG. //Added references using ArcGIS.Desktop.Framework.Threading.Tasks; //QueuedTask using ArcGIS.Desktop.Mapping; //MapView and Export formats public class ExportActiveMapToPNGExample { public static Task ExportActiveMapToPNGAsync(string Path) { return QueuedTask.Run(() => { //Reference the active map view MapView mapv = MapView.Active; //Create PNG format with appropriate settings PNGFormat PNG = new PNGFormat(); PNG.Resolution = 300; PNG.Height = 500; PNG.Width = 800; PNG.OutputFileName = Path; //Export active map view if (PNG.ValidateOutputFilePath()) { mapv.Export(PNG); } }); } }
PNGFormat PNG = new PNGFormat();
System.Object
ArcGIS.Desktop.Mapping.ExportFormat
ArcGIS.Desktop.Mapping.PNGFormat
Target Platforms: Windows 11, Windows 10, Windows 8.1