Hi, I'm trying to dynamically export my data driven pages to an PDF. Right now, the script successfully creates the data driven pages. We have to manually hit the "Refresh" button and then
manually do File -> Export to PDF.
I've tried this 2 ways (Option 1 & 2 below).
For some reason, it's erroring out on any code the tries to use dataDrivenPages functionality.
Has anyone witnessed this before or see what I'm doing wrong? I have to 2 options commented out for now.
Thanks,
Chris
# Import arcpy module
import arcpy
arcpy.env.overwriteOutput = True
mxd = arcpy.mapping.MapDocument("CURRENT")
# Script arguments
Map_Scale = arcpy.GetParameterAsText(0)
Page_Size = arcpy.GetParameterAsText(1)
Output_Grids = arcpy.GetParameterAsText(2)
Stand_Layer = arcpy.GetParameterAsText(3)
# Process: Verify Page Size
if Page_Size == "11 x 17":
Page_Width = "9.5 Inches"
Page_Height = "13.5 Inches"
else:
Page_Width = "7 Inches"
Page_Height = "8 Inches"
# Process: Grid Index Features
arcpy.GridIndexFeatures_cartography(Output_Grids, Stand_Layer, "INTERSECTFEATURE", "USEPAGEUNIT", Map_Scale, Page_Width, Page_Height, "", "", "", "", "NO_LABELFROMORIGIN")
arcpy.SetParameterAsText(4, Output_Grids)
# Option 1
#mxd.dataDrivenPages.refresh()
#arcpy.mapping.ExportToPDF(mxd, r"D:\Clearion Data\testExport.pdf")
# Option 2
#tempPDF = r"D:\Data\testExport.pdf"
#ddp = mxd.dataDrivenPages
#ddp.exportToPDF(tempPDF, "ALL"}