Solved! Go to Solution.
for mxdPath in mxdList: arcpy.AddMessage(mxdPath) if os.path.exists(mxdPath): mxd = arcpy.mapping.MapDocument(mxdPath) #name = mxdPath[:-4] + ".pdf" name = mxdPath.replace('.mxd', '.pdf', -1) file = dir + os.sep + os.path.basename(name) ddp = mxd ddp.exportToPDF(file, "ALL")
tags when posting code to retain indentation.
all I have is one page\layout\dataframe per mxd...you may not even need data driven pages. Here is a simple export from a list of mxd names:
import arcpy, os mxdList = ['C:/temp/Counties.mxd','C:/temp/Counties2.mxd'] for mxdPath in mxdList: print mxdPath mxd = arcpy.mapping.MapDocument(mxdPath) output = mxdPath.replace('.mxd', '.pdf', -1) print output arcpy.mapping.ExportToPDF(mxd, output) print 'done'
import arcpy, os folderPath = r"C:\Temp\Forum" for filename in os.listdir(folderPath): fullpath = os.path.join(folderPath, filename) if os.path.isfile(fullpath): basename, extension = os.path.splitext(fullpath) if extension.lower() == ".mxd": mxd = arcpy.mapping.MapDocument(fullpath) arcpy.mapping.ExportToPDF(mxd, basename + '.pdf')
ddp = mxd
ddp = mxd.dataDrivenPages