import arcpy, os, datetime
folderPath = r"C:\path"
dateTimeStamp = time.strftime('%Y%m%d')
basename = "Flows"
mxd = arcpy.mapping.MapDocument(r"C:\path\file.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
#loops through bookmarked locations and executes a PDF export
for bkmk in arcpy.mapping.ListBookmarks(mxd, "",data_frame=df):
#going through text elements to find the map title and set it to the bookmark name
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "documentTitle"):
elm.text = str(bkmk.name) + " - Flows"
#set extent to bookmark extent before pdf export
df.extent = bkmk.extent
print basename + "_" + bkmk.name + " is exporting to PDF"
arcpy.mapping.ExportToPDF(mxd, basename + "_" + bkmk.name + "_" + dateTimeStamp)
print basename + "_" + bkmk.name + " successfully exported to PDF"
print "Done exporting this folder to PDF - " +folderPath
#cleanup
del mxd
I'm receiving the following error after attempting to loop through about 10 bookmarks worth of PDF exports. The odd thing is, if I do 3-4 bookmarks at a time, it will export successfully but not if I do the full set of 10.
AttributeError: PageLayoutObject: Error in executing ExportToPDF