HOW TO
Instructions provided describe how to export multiple map documents (.mxd) to PDF using a Python script.
The following code sample accesses a workspace, creates a list of existing .mxd files in the workspace, iterates through each .mxd, and exports to PDF.
Code: import arcpy, os arcpy.env.workspace = ws = r"C:\\My_Folder" mxd_list = arcpy.ListFiles("*.mxd") for mxd in mxd_list: current_mxd = arcpy.mapping.MapDocument(os.path.join(ws, mxd)) pdf_name = mxd[:-4] + ".pdf" arcpy.mapping.ExportToPDF(current_mxd, pdf_name) del mxd_list
To set the desired resolution, width, and height, insert the following variables after setting the workspace, and insert the new parameters into the ExportToPDF function. The following code is a sample of how the full script looks:
Code: import arcpy, os arcpy.env.workspace = ws = r"C:\\My_Folder" resolution = "600" width = 640 height = 480 mxd_list = arcpy.ListFiles("*.mxd") for mxd in mxd_list: current_mxd = arcpy.mapping.MapDocument(os.path.join(ws, mxd)) pdf_name = mxd[:-4] + ".pdf" arcpy.mapping.ExportToPDF(current_mxd, pdf_name, resolution, width, height) del mxd_list
Note: The code can also be used as a standalone Python script. This enables users to convert multiple MXD files without opening ArcMap.
Get help from ArcGIS experts
Download the Esri Support App