ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / EMFFormat Class
Members Example

In This Topic
    EMFFormat Class
    In This Topic
    Represents an Enhanced Metafile Format (EMF) object that can be used to export a MapView, MapFrame, or a Layout.
    Syntax
    public class EMFFormat : ExportFormat 
    Public Class EMFFormat 
       Inherits ExportFormat
    Remarks
    EMF files are native Windows graphics files that can contain a mixture of vector and raster data. They are useful for embedding in Windows documents because the vector portions of the EMF can be resized without loss of quality. However, since EMF does not support font embedding and is exclusively a Windows format, it is not commonly used as an interchange format between users.
    Example
    ExportEMF_Layout
    //This example demonstrates how to export a layout to EMF.
    
    //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 ExportLayoutToEMFExample
    {
      public static Task ExportLayoutToEMFAsync(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 EMF format with appropriate settings
        EMFFormat EMF = new EMFFormat();
        EMF.Resolution = 300;
        EMF.OutputFileName = Path;
    
        return QueuedTask.Run(() =>
        {
                //Export Layout
                Layout lyt = layoutItem.GetLayout(); //Loads and returns the layout associated with a LayoutItem
                if (EMF.ValidateOutputFilePath())
          {
            lyt.Export(EMF);
          }
        });
      }
    }
    ExportEMF_MapFrame
    //This example demonstrates how to export an individual map frame on a layout to EMF.
    
    //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 ExportMapFrameToEMFExample
    {
      public static Task ExportMapFrameToEMFAsync(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 EMF format with appropriate settings
        EMFFormat EMF = new EMFFormat();
        EMF.Resolution = 300;
        EMF.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;
          EMF.OutputFileName = Path;
          if (EMF.ValidateOutputFilePath())
          {
            mf.Export(EMF);
          }
        });
      }
    }
    ExportEMF_ActiveMap
    //This example demonstrates how to export the active mapview to EMF.
    
    //Added references
    using ArcGIS.Desktop.Framework.Threading.Tasks;    //QueuedTask
    using ArcGIS.Desktop.Mapping;                      //MapView and Export formats
    
    public class ExportActiveMapToEMFExample
    {
      public static Task ExportActiveMapToEMFAsync(string Path)
      {
        return QueuedTask.Run(() =>
        {
                //Reference the active map view
                MapView map = MapView.Active;
    
                //Create EMF format with appropriate settings
                EMFFormat EMF = new EMFFormat();
          EMF.Resolution = 300;
          EMF.Height = 500;
          EMF.Width = 800;
          EMF.OutputFileName = Path;
    
                //Export active map view
                if (EMF.ValidateOutputFilePath())
          {
            map.Export(EMF);
          }
        });
      }
    }
    EMF_Constructor
    EMFFormat EMF = new EMFFormat();
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Mapping.ExportFormat
          ArcGIS.Desktop.Mapping.EMFFormat

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also