<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: [bug] mapSeries.exportToPDF - no suffix for single page range in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/bug-mapseries-exporttopdf-no-suffix-for-single/m-p/1512440#M71155</link>
    <description>&lt;P&gt;Here is something I use,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;import arcpy

def export_map_series(map_series, output_path, custom_range_type, page_range_string, custom_multiple_files_option):
    # Check if the page_range_string is a single page
    if custom_range_type == "CUSTOM_RANGE" and custom_multiple_files_option in ["CUSTOM_PAGE_NUMBER", "CUSTOM_PAGE_NAME"]:
        pages = page_range_string.split(",")
        if len(pages) == 1:
            # Duplicate the page number if it's a single page
            page_range_string = f"{pages[0]},{pages[0]}"
    
    # Map custom names to ArcGIS Pro export options
    range_type_mapping = {
        "CUSTOM_RANGE": "RANGE"
    }
    
    multiple_files_mapping = {
        "CUSTOM_PAGE_NUMBER": "PDF_MULTIPLE_PAGE_NUMBER",
        "CUSTOM_PAGE_NAME": "PDF_MULTIPLE_PAGE_NAME"
    }
    
    # Perform the export
    map_series.exportToPDF(output_path, 
                           page_range_type=range_type_mapping[custom_range_type], 
                           page_range_string=page_range_string, 
                           multiple_files=multiple_files_mapping[custom_multiple_files_option])

# Example usage
project = arcpy.mp.ArcGISProject("CURRENT")
layout = project.listLayouts()[0]  # Assuming the first layout is the one you want to use
map_series = layout.mapSeries
output_path = r"C:\Temp\CaseMaps.pdf"
custom_range_type = "CUSTOM_RANGE"
page_range_string = "1"  # Change this to test with a single page
custom_multiple_files_option = "CUSTOM_PAGE_NUMBER"

export_map_series(map_series, output_path, custom_range_type, page_range_string, custom_multiple_files_option)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Jul 2024 16:32:39 GMT</pubDate>
    <dc:creator>TonyAlmeida</dc:creator>
    <dc:date>2024-07-30T16:32:39Z</dc:date>
    <item>
      <title>[bug] mapSeries.exportToPDF - no suffix for single page range</title>
      <link>https://community.esri.com/t5/python-questions/bug-mapseries-exporttopdf-no-suffix-for-single/m-p/1510357#M71124</link>
      <description>&lt;P&gt;When exporting a map series with&amp;nbsp;mapSeries.exportToPDF, if the&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;page_range_string&lt;/STRONG&gt; is a single page with&amp;nbsp;&lt;STRONG&gt;page_range_type&lt;/STRONG&gt;="&lt;EM&gt;RANGE&lt;/EM&gt;" and&amp;nbsp;&lt;STRONG&gt;multiple_files&lt;/STRONG&gt;=["&lt;EM&gt;PDF_MULTIPLE_FILES_PAGE_NUMBER&lt;/EM&gt;" | "&lt;EM&gt;PDF_MULTIPLE_FILES_PAGE_NAME&lt;/EM&gt;"], a suffix is not added.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;map_series.exportToPDF("path/to/test.pdf", page_range_type="RANGE",page_range_string="1", multiple_files="PDF_MULTIPLE_FILES_PAGE_NUMBER")
# "path/to/test.pdf"

map_series.exportToPDF("path/to/test.pdf", page_range_type="RANGE",page_range_string="1,2", multiple_files="PDF_MULTIPLE_FILES_PAGE_NUMBER")
# "path/to/test_1.pdf"
# "path/to/test_2.pdf"&lt;/LI-CODE&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I can see this being considered expected behaviour, but it is problematic when batching multiple exports for dynamic ranges and inconsistent with the documentation:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;PDF_MULTIPLE_FILES_PAGE_NUMBER&lt;/SPAN&gt;—&lt;SPAN&gt;Export each map series page to an individual file and append the page number to the file name. For example, Output.PDF will become Output_1.PDF&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;The simplest workaround, that I currently employ, is to specify the page twice, when the range is 1.&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 25 Jul 2024 22:59:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/bug-mapseries-exporttopdf-no-suffix-for-single/m-p/1510357#M71124</guid>
      <dc:creator>TaylorCarnell1</dc:creator>
      <dc:date>2024-07-25T22:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: [bug] mapSeries.exportToPDF - no suffix for single page range</title>
      <link>https://community.esri.com/t5/python-questions/bug-mapseries-exporttopdf-no-suffix-for-single/m-p/1512440#M71155</link>
      <description>&lt;P&gt;Here is something I use,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;import arcpy

def export_map_series(map_series, output_path, custom_range_type, page_range_string, custom_multiple_files_option):
    # Check if the page_range_string is a single page
    if custom_range_type == "CUSTOM_RANGE" and custom_multiple_files_option in ["CUSTOM_PAGE_NUMBER", "CUSTOM_PAGE_NAME"]:
        pages = page_range_string.split(",")
        if len(pages) == 1:
            # Duplicate the page number if it's a single page
            page_range_string = f"{pages[0]},{pages[0]}"
    
    # Map custom names to ArcGIS Pro export options
    range_type_mapping = {
        "CUSTOM_RANGE": "RANGE"
    }
    
    multiple_files_mapping = {
        "CUSTOM_PAGE_NUMBER": "PDF_MULTIPLE_PAGE_NUMBER",
        "CUSTOM_PAGE_NAME": "PDF_MULTIPLE_PAGE_NAME"
    }
    
    # Perform the export
    map_series.exportToPDF(output_path, 
                           page_range_type=range_type_mapping[custom_range_type], 
                           page_range_string=page_range_string, 
                           multiple_files=multiple_files_mapping[custom_multiple_files_option])

# Example usage
project = arcpy.mp.ArcGISProject("CURRENT")
layout = project.listLayouts()[0]  # Assuming the first layout is the one you want to use
map_series = layout.mapSeries
output_path = r"C:\Temp\CaseMaps.pdf"
custom_range_type = "CUSTOM_RANGE"
page_range_string = "1"  # Change this to test with a single page
custom_multiple_files_option = "CUSTOM_PAGE_NUMBER"

export_map_series(map_series, output_path, custom_range_type, page_range_string, custom_multiple_files_option)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2024 16:32:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/bug-mapseries-exporttopdf-no-suffix-for-single/m-p/1512440#M71155</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2024-07-30T16:32:39Z</dc:date>
    </item>
  </channel>
</rss>

