AnsweredAssumed Answered

Arcpy Map Series- export using page name as output?

Question asked by terrafirma_theo on Feb 21, 2018
Latest reply on Feb 21, 2018 by terrafirma_theo

ArcGIS Pro 2.1.1, python 3.6.2

 

I have a standalone python script which cycles through multiple map extents and exports each as seperate PDF files. However, currently the PDFs are exported as FILENAME_[Page Number].pdf. I want it to be FILENAME_[Page Name].pdf

 

Is it as simple as replacing 'ms.currentPageNumber' and 'pageNum' with 'ms.currentPageName' and 'pageNam'? (if those even exists!)

I guess the {0} would also need to disappearin the last line, as there won't be any page number in the file name.

 

import arcpy, os, sys
relpath = os.path.dirname(sys.argv[0])

p = arcpy.mp.ArcGISProject("C:\\Automation\\Automation.aprx")
print ("project located")
l = p.listLayouts()[0]
print ("layouts listed")
if not l.mapSeries is None:
  ms = l.mapSeries
  if ms.enabled:
    for pageNum in range(1, ms.pageCount + 1):
      ms.currentPageNumber = pageNum
      print("Exporting page {0} of {1}".format(str(ms.currentPageNumber), str(ms.pageCount)))
      l.exportToPDF("C:\\Users\\Default\\Production\\Completed_certificates\\FILENAME_{0}".format(str(ms.currentPageNumber) + ".pdf"))

Outcomes