Im trying to export data driven pages (Mapbook) and have the resulting PDF named for a/the index field. Here's the code snippit I am working on:
mport arcpy print "Setting Map Document. . ." mxd = arcpy.mapping.MapDocument("CURRENT") for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1): mxd.dataDrivenPages.currentPageID = pageNum pageName = mxd.dataDrivenPages.pageRow.stand_key print "Exporting page {0} of {1}".format(str(mxd.dataDrivenPages.currentPageID), str (mxd.dataDrivenPages.pageCount)) arcpy.mapping.ExportToPDF(mxd, r"D:\Temp\Test" + str(pageName) + ".pdf") del mxd
This works just fine, but "Test" is a prefix of the filename. If i remove the "Test" and have and make the code like this below...it doesn't work. Just to be clear I need the individually exported PDF page to be named for the value of str(pageName)
import arcpy ... print "Setting Map Document. . ." ... mxd = arcpy.mapping.MapDocument("CURRENT") ... for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1): ... mxd.dataDrivenPages.currentPageID = pageNum ... pageName = mxd.dataDrivenPages.pageRow.stand_key ... print "Exporting page {0} of {1}".format(str(mxd.dataDrivenPages.currentPageID), str (mxd.dataDrivenPages.pageCount)) ... arcpy.mapping.ExportToPDF(mxd, r"D:\Temp" + str(pageName) + ".pdf") ... del mxd
Should I be using something other than arcpy.mapping.ExportToPDF? Other Solution?
Should