HOW TO

Assign dynamic PDF metadata titles to exported map series files using Python in ArcGIS Pro

First Published: May 29, 2026
Last Published: May 29, 2026

Summary

In ArcGIS Pro, when a map series is exported to multiple PDF files, only one metadata title is applied to all exported files. This article describes the workflow to dynamically assign a unique title to each PDF file during the export process using Python. This workflow is only applicable for spatial map series.

Procedure

Note:
Ensure the pikepdf module is installed in a cloned environment before starting the workflow. Refer to ArcGIS API for Python: Using ArcGIS Pro 3.0 and later for more information.
  1. Open the project in ArcGIS Pro.
  2. On the View ribbon tab, in the Windows group, click Contents.
  3. Expand the map and right-click the layer. In this example, it is MapSeries_Index.
The MapSeries_Index layer in Contents pane
  1. Click Attribute Table to open the layer's attribute table.
  2. In the attribute table view, click the Add Field The Add Field icon icon to add a field.
  1. In the Fields view, under the Field Name column, specify a name for the new field. In this example, it is PageName.
The Field Name column
  1. Under the Data Type column, double-click the cell and select Text.
  2. On the Fields tab, in the Manage Edits group, click Save. Close the Fields view.
  3. Double-click the cell in the new field to edit the cell value with the preferred title.
The table cell of the PageName field
  1. On the View ribbon tab, in the Windows group, click Python Window.
  2. In the Python window, copy and paste the following code to update the PDF metadata title after the map series page is exported in the Contents pane:
Note:
Avoid pressing Enter between lines, as it creates indentation errors. The full script must be run at once.
  1. Import the Python libraries.
import arcpy, os, pikepdf
  1. Define the layout name and specify the output folder for the exported PDF files.
LAYOUT_NAME = "MapSeries_Layout"
OUTPUT_FOLDER = r"C:\Users\Folder_path"
  1. Retrieve the current project and layout in ArcGIS Pro.
aprx = arcpy.mp.ArcGISProject("CURRENT")
layout = aprx.listLayouts(LAYOUT_NAME)[0]
ms = layout.mapSeries
  1. Verify that the map series is enabled in the layout and create an output folder if one does not already exist.
if not ms or not ms.enabled:
    raise RuntimeError("Map Series is not enabled on the layout.")

os.makedirs(OUTPUT_FOLDER, exist_ok=True)
  1. Create the file path for the exported PDF files.
for i in range(1, ms.pageCount + 1):

    # Switch to the current Map Series page
    ms.currentPageNumber = i
    page_name = ms.pageRow.PageName
    pdf_path = os.path.join(OUTPUT_FOLDER, f"{page_name}.pdf")
  1. Export the PDF files.
    layout.exportToPDF(pdf_path)
  1. Update the PDF metadata titles and display a message.
    with pikepdf.open(pdf_path, allow_overwriting_input=True) as pdf:
        pdf.docinfo["/Title"] = f"Map Series Page – {page_name}"
        pdf.save(pdf_path)

    print(f"Updated PDF Title for: {page_name}")

print("Finished exporting and updating PDF titles.")

The following code shows the full sample script:

import arcpy, os, pikepdf

LAYOUT_NAME = "MapSeries_Layout"
OUTPUT_FOLDER = r"C:\Users\ana\Desktop\Exported PDF"

aprx = arcpy.mp.ArcGISProject("CURRENT")
layout = aprx.listLayouts(LAYOUT_NAME)[0]
ms = layout.mapSeries

if not ms or not ms.enabled:
    raise RuntimeError("Map Series is not enabled on the layout.")

os.makedirs(OUTPUT_FOLDER, exist_ok=True)

for i in range(1, ms.pageCount + 1):

    # Switch to the current Map Series page
    ms.currentPageNumber = i
    page_name = ms.pageRow.PageName
    pdf_path = os.path.join(OUTPUT_FOLDER, f"{page_name}.pdf")

    # --- EXPORT (ArcPy) ---
    layout.exportToPDF(pdf_path)

    # --- UPDATE PDF METADATA (pikepdf) ---
    with pikepdf.open(pdf_path, allow_overwriting_input=True) as pdf:
        pdf.docinfo["/Title"] = f"Map Series Page – {page_name}"
        pdf.save(pdf_path)

    print(f"Updated PDF Title for: {page_name}")

print("Finished exporting and updating PDF titles.")

The output below displays the unique metadata titles assigned to the exported PDF files.

The output message displayed in the Python window

Article ID: 000041542

Software:
  • ArcGIS Pro

Get support with AI

Resolve your issue quickly with the Esri Support AI Chatbot.

Start chatting now

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Start chatting now

Go to download options