Export to PNG by DDP Page Name instead of PageNum

825
1
03-27-2013 04:12 AM
SusanZwillinger
Occasional Contributor
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
Tags (2)
0 Kudos
1 Reply
JeffMoulds
Esri Contributor
Hello,

Check out this thread. It should do what you want.
0 Kudos