AnsweredAssumed Answered

How to export pdf from data driven pages using page name?

Question asked by ufeliciano on Feb 20, 2015
Latest reply on Feb 24, 2015 by thebillcarr

I want to export pdf from data driven pages from a standalone python script.  So far I have the following code that works fine...


import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Workspace\DELETEME\TestDDP\dds_test.mxd")
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
    mxd.dataDrivenPages.currentPageID = pageNum
    print "Exporting page {0} of {1}".format(str(mxd.dataDrivenPages.currentPageID), str(mxd.dataDrivenPages.pageCount))
    arcpy.mapping.ExportToPDF(mxd, r"C:\Workspace\DELETEME\TestDDP" + str(pageNum) + ".pdf")
del mxd


The issue is that I want the file to be name as the page name and not the page ID.  Thing is that my grid feature class jumps from grid_id 123 to 125, but page number shows the sequential number of pages, altought I set page number field to grid_id also.  Grid_ID and GRID_NAME in my feature class have the same value, but due to the jump in values, the generated pdf file 124 is actually representing the map for grid 125.


Any help is appreciated...