I have folder having multiple single mxd and mxd's having data driven pages. I am trying to get the pdf's of each of these MXD's.if mxd's has a data driven pages then all the pages from a same mxd document needs to save in a single pdf. What part of the below mentioned script will change so that it will consider the data driven pages.Right now this script is only exporting pdf from multiple single mxd document and not considering data driven pages. Need your suggestion for the same!!
>>> #Multiple single MXD's and Multiple datadriven pages in a single folder.
import arcpy, os
#Read input parameter from user.
#path = arcpy.GetParameterAsText(0)
path = r'Z:\Tier3\TrainControls\NonReportSpecific\2015_FINAL_PresentationMaps\MXD\REVISED\test'
#Write MXD names in folder to txt log file.
writeLog=open(path+"\FileListLog.txt","w")
for fileName in os.listdir(path):
fullPath = os.path.join(path, fileName)
if os.path.isfile(fullPath):
basename, extension = os.path.splitext(fullPath)
if extension == ".mxd":
writeLog.write(fullPath+"\n")
mxd = arcpy.mapping.MapDocument(fullPath)
print fileName + "\n"
del mxd
print "Done"
writeLog.close()
#exportPath =arcpy.GetParameterAsText(1)
exportPath = r'Z:\Tier3\TrainControls\NonReportSpecific\2015_FINAL_PresentationMaps\MXD\REVISED\test'
MXDread=open(path+"\FileListLog.txt","r")
for line in MXDread:
#Strip newline from line.
line=line.rstrip('\n')
if os.path.isfile(line):
basename, extension = os.path.splitext(line)
newName=basename.split('\\')[-1]
if extension.lower() == ".mxd":
print "Basename:" +newName
mxd = arcpy.mapping.MapDocument(line)
newPDF=exportPath+"\\"+newName+".pdf"
print newPDF
if "DDP enabled mxd":
ddp = mxd.dataDrivenPages
ddp.exportToPDF(tmpPdf,"ALL")
finalPdf.appendPages(tmpPdf)
else:
arcpy.mapping.ExportToPDF(mxd,newPDF)
print line + "Export Done"
MXDread.close()
item=path+"\FileListLog.txt"
os.remove(item)
del mxd
BergenCountyLine_KeyMap.mxd
BergenCountyLine_SurveyAssets.mxd
Done
Basename:BergenCountyLine_KeyMap
Z:\Tier3\TrainControls\NonReportSpecific\2015_FINAL_PresentationMaps\MXD\REVISED\test\BergenCountyLine_KeyMap.pdf
Runtime error
Traceback (most recent call last):
File "<string>", line 38, in <module>
File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\arcobjects\mixins.py", line 612, in dataDrivenPages
return convertArcObjectToPythonObject(self._arc_object.pageLayout.dataDrivenPages)
AttributeError: Data Driven Pages is not enabled on this map document.