I am a novice Python user but I am trying to create a script which will allow me to export all of the data driven pages within an mxd to a single pdf file (without having to open the mxd). I currently have the script below which works for exporting single pages. And the highlighted section was my initial (poor) attempt to export all pages based on what I have seen or read.
# Python script to run in windows. # 1) Copy script into folder to run script # 2) Edit quality and dpi variables if desired import arcpy, os # get current directory python script is in cwd = os.getcwd() # quality to export, BEST, BETTER, NORMAL, FASTER, FASTEST quality = "BEST" # dots per inch resolution dpi = "300" res = int(dpi) # Ask user to confirm settings and directory print "Export ArcMap MXD(s) to PDF(s), " + quality + " Quality, " + dpi + "dpi to " + cwd + "?" # pauses for user to press key to continue os.system('pause') # set folder path to current directory folderPath = cwd # prints message to console for user print "IN PROGRESS...PLEASE WAIT..." # counter to count number of PDFs n = 0 # create fullpath from filename and folder path for filename in os.listdir(folderPath): fullpath = os.path.join(folderPath, filename) # extract file extension if os.path.isfile(fullpath): basename, extension = os.path.splitext(fullpath) if extension.lower() == ".mxd": # advance counter to count PDFs n = n + 1 mxd = arcpy.mapping.MapDocument(fullpath) # export tool with parameters arcpy.mapping.ExportToPDF(mxd, basename + '.pdf', resolution=res, image_quality=quality, colorspace="RGB", picture_symbol="VECTORIZE_BITMAP", layers_attributes="NONE") print basename + "...exported" del mxd # prints message to console for user nstr = str(n) print nstr + " pdf(s) exported to " + folderPath print "DONE" # pauses for user to press key to continue os.system('pause')