ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / ExportFormat Class / ValidateOutputFilePath Method
Example

In This Topic
    ValidateOutputFilePath Method (ExportFormat)
    In This Topic
    Validates the output file path.
    Syntax
    Public Overridable Function ValidateOutputFilePath() As Boolean
    public virtual bool ValidateOutputFilePath()
    Example
    Export a layout to PDF
    {
      //Export a single page layout to PDF.
    
      //Create a PDF format with appropriate settings
      //BMP, EMF, EPS, GIF, JPEG, PNG, SVG, TGA, and TFF formats are also available for export
      string filePath = @"Path and file name for the output export file";
      PDFFormat PDF = new PDFFormat()
      {
        OutputFileName = filePath,
        Resolution = 300,
        DoCompressVectorGraphics = true,
        DoEmbedFonts = true,
        HasGeoRefInfo = true,
        ImageCompression = ImageCompression.Adaptive,
        ImageQuality = ImageQuality.Best,
        LayersAndAttributes = LayersAndAttributes.LayersAndAttributes
      };
    
      //Check to see if the path is valid and export
      if (PDF.ValidateOutputFilePath())
      {
        //Note: Must be on QueuedTask.Run
        layout.Export(PDF);  //Export the layout to PDF on the worker thread
      }
    }
    Export a map frame to JPG
    {
      //Export a map frame to JPG.
      string filePath = @"Path and file name for the output export file";
      //Create JPEG format with appropriate settings
      //BMP, EMF, EPS, GIF, PDF, PNG, SVG, TGA, and TFF formats are also available for export
      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
      //Note: Must be on QueuesTask.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.
      string filePath = @"Path and file name for the output export file";
      //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
      };
    
      //Export on the worker thread
      await QueuedTask.Run(() =>
      {
        MapView mv_bmp = mapFrame.GetMapView(layoutView);
        if (mv_bmp != null)
        {
          //Check to see if the path is valid and export
          if (BMP.ValidateOutputFilePath())
          {
            mv_bmp.Export(BMP);  //Export to BMP
          }
        }
      });
    }
    Export a map series to single PDF
    {
      //Export a map series with multiple pages to a single PDF.
      string filePath = @"Path and file name for the output export file";
      //Create PDF format with appropriate settings
      PDFFormat MS_PDF = new PDFFormat()
      {
        OutputFileName = filePath,
        Resolution = 300,
        DoCompressVectorGraphics = true,
        DoEmbedFonts = true,
        HasGeoRefInfo = true,
        ImageCompression = ImageCompression.Adaptive,
        ImageQuality = ImageQuality.Best,
        LayersAndAttributes = LayersAndAttributes.LayersAndAttributes
      };
    
      //Set up map series export options
      MapSeriesExportOptions MS_ExportOptions = new MapSeriesExportOptions()
      {
        ExportPages = ExportPages.Custom,  //Provide a specific list of pages
        CustomPages = "1-3, 5",  //Only used if ExportPages.Custom is set
        ExportFileOptions = ExportFileOptions.ExportAsSinglePDF,  //Export all pages to a single, multi-page PDF
        ShowSelectedSymbology = false  //Do no show selection symbology in the output
      };
    
      //Export on the worker thread
      //Note: Must be on QueuedTask.Run
      //Check to see if the path is valid and export
      if (MS_PDF.ValidateOutputFilePath())
      {
        layout.Export(MS_PDF, MS_ExportOptions);  //Export to PDF
      }
    }
    Export a map series to individual TIFF files
    {
      //Export each page of a map series to an individual TIFF file.
      string filePath = @"Path and file name for the output export file";
      //Create TIFF format with appropriate settings
      TIFFFormat TIFF = new TIFFFormat()
      {
        OutputFileName = filePath,
        Resolution = 300,
        ColorMode = TIFFColorMode.TwentyFourBitTrueColor,
        HasGeoTiffTags = true,
        HasWorldFile = true,
        ImageCompression = TIFFImageCompression.LZW
      };
    
      //Set up map series export options
      MapSeriesExportOptions MSExportOptions_TIFF = new MapSeriesExportOptions()
      {
        ExportPages = ExportPages.All,  //All pages
        ExportFileOptions = ExportFileOptions.ExportMultipleNames,  //Export each page to an individual file using page name as a suffix.
        ShowSelectedSymbology = true  //Include selection symbology in the output
      };
    
      //Export on the worker thread
      //Note: Must be on the QueuedTask.Run()
    
      //Check to see if the path is valid and export
      if (TIFF.ValidateOutputFilePath())
      {
        layout.Export(TIFF, MSExportOptions_TIFF);  //Export to TIFF
      }
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also