szwillinger

Export to PNG by DDP Page Name instead of PageNum

Discussion created by szwillinger on Mar 27, 2013
Latest reply on Mar 27, 2013 by jmoulds-esristaff
I am surprised that this has not been documented previously, but my search did not yield any results.  Here's my question: There is sample code to export all of your data driven pages to individual PNG files with the page number at the end of the file name.  How do I change the code to create file names that use the page name index value instead of the page number?

Here's the sample code:

mxd = arcpy.mapping.MapDocument("CURRENT")
... for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
...   mxd.dataDrivenPages.currentPageID = pageNum
...   arcpy.mapping.ExportToPNG(mxd, r"C:\ArcGIS\Map_Area_" + str(pageNum) + ".png")
... del mxd

Outcomes