import arcpy import os from os.path import isdir, join, normpath, split mxd = arcpy.mapping.MapDocument("Current") wPath = r"Y:\Notification Radius Pkgs\dave500\\" RequestID = "Dave Jordan" try: pdfPath = wPath+RequestID+".pdf" arcpy.AddMessage(pdfPath) if os.path.exists(pdfPath): os.remove(pdfPath) #Create the file and append pages pdfDoc = arcpy.mapping.PDFDocumentCreate(pdfPath) for file in os.listdir(wPath): if file.endswith(".pdf"): arcpy.AddMessage("Adding "+file) pdfDoc.appendPages(wPath+file) #Commit changes and delete variable reference pdfDoc.saveAndClose() del pdfDoc except Exception, e: import traceback map(arcpy.AddError, traceback.format_exc().split("\n")) arcpy.AddError(str(e))
Solved! Go to Solution.
import arcpy import os from os.path import isdir, join, normpath, split mxd = arcpy.mapping.MapDocument("Current") wPath = r"Y:\Notification Radius Pkgs\dave500\\" RequestID = "Dave Jordan" try: pdfPath = wPath+RequestID+".pdf" arcpy.AddMessage(pdfPath) if os.path.exists(pdfPath): os.remove(pdfPath) #Create the file and append pages pdfDoc = arcpy.mapping.PDFDocumentCreate(pdfPath) for file in os.listdir(wPath): if file.endswith(".pdf"): arcpy.AddMessage("Adding "+file) pdfDoc.appendPages(wPath+file) #Commit changes and delete variable reference pdfDoc.saveAndClose() del pdfDoc except Exception, e: import traceback map(arcpy.AddError, traceback.format_exc().split("\n")) arcpy.AddError(str(e))
import arcpy import os from os.path import isdir, join, normpath, split mxd = arcpy.mapping.MapDocument("Current") wPath = r"Y:\Notification Radius Pkgs\dave500\\" RequestID = "Dave Jordan" try: pdfPath = wPath+RequestID+".pdf" arcpy.AddMessage(pdfPath) if os.path.exists(pdfPath): os.remove(pdfPath) #Create the file and append pages pdfDoc = arcpy.mapping.PDFDocumentCreate(pdfPath) for file in os.listdir(wPath): if file.endswith(".pdf"): arcpy.AddMessage("Adding "+file) pdfDoc.appendPages(wPath+file) #Commit changes and delete variable reference pdfDoc.saveAndClose() del pdfDoc except Exception, e: import traceback map(arcpy.AddError, traceback.format_exc().split("\n")) arcpy.AddError(str(e))