ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / SVGFormat Class
Members Example

In This Topic
    SVGFormat Class
    In This Topic
    Represents a Scalable Vector Graphics (SVG) object that can be used to export a MapView, MapFrame, or a Layout.
    Syntax
    public class SVGFormat : ExportFormat 
    Public Class SVGFormat 
       Inherits ExportFormat
    Remarks
    SVG is an XML-based file format that has been specifically designed for viewing on the Web. SVG can contain both vector and raster information. This is a good choice for displaying maps on a web page because it is rescalable and more easily edited than raster files. SVG has been gaining in popularity since the World Wide Web Consortium (W3C) selected it as their standard vector Web format. Some Web browsers may require a plug-in to view SVG files; older browsers may not be able to view SVG files at all.
    Example
    ExportSVG_Layout
    //This example demonstrates how to export a layout to SVG.
    
    //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 ExportLayoutToSVGExample
    {
      public static Task ExportLayoutToSVGAsync(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 SVG format with appropriate settings
        SVGFormat SVG = new SVGFormat();
        SVG.Resolution = 300;
        SVG.OutputFileName = Path;
    
        return QueuedTask.Run(() =>
        {
                //Export Layout
                Layout lyt = layoutItem.GetLayout(); //Loads and returns the layout associated with a LayoutItem
                if (SVG.ValidateOutputFilePath())
          {
            lyt.Export(SVG);
          }
        });
      }
    }
    ExportSVG_MapFrame
    //This example demonstrates how to export an individual map frame on a layout to SVG.
    
    //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 ExportMapFrameToSVGExample
    {
      public static Task ExportMapFrameToSVGAsync(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 SVG format with appropriate settings
        SVGFormat SVG = new SVGFormat();
        SVG.Resolution = 300;
        SVG.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;
          SVG.OutputFileName = Path;
          if (SVG.ValidateOutputFilePath())
          {
            mf.Export(SVG);
          }
        });
      }
    }
    ExportSVG_ActiveMap
    //This example demonstrates how to export the active mapview to SVG.
    
    //Added references
    using ArcGIS.Desktop.Framework.Threading.Tasks;    //QueuedTask
    using ArcGIS.Desktop.Mapping;                      //MapView and  Export formats
    
    public class ExportActiveMapToSVGExample
    {
      public static Task ExportActiveMapToSVGAsync(string Path)
      {
        return QueuedTask.Run(() =>
        {
                //Reference the active map view
                MapView mapv = MapView.Active;
    
                //Create SVG format with appropriate settings
                SVGFormat SVG = new SVGFormat();
          SVG.Resolution = 300;
          SVG.Height = 500;
          SVG.Width = 800;
          SVG.OutputFileName = Path;
    
                //Export active map view
                if (SVG.ValidateOutputFilePath())
          {
            mapv.Export(SVG);
          }
        });
      }
    }
    SVG_Constructor
    SVGFormat SVG = new SVGFormat();
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Mapping.ExportFormat
          ArcGIS.Desktop.Mapping.SVGFormat

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also