AnsweredAssumed Answered

Help with Script Tool for Creating PDFs from MXDs

Question asked by MLCouden on Feb 22, 2013
Latest reply on Feb 27, 2013 by MLCouden
I need a little help. I have made a script tool to use to export my mxds into a pdf. It would be a single mxd into a single pdf. I am getting an error that the mxd path is incorrect. I have included my script below. Any help would be great!

# Necessary modules
import arcpy, os, string, sys

# For less complicated scripts -
# these 2 imports are necessary to utilize a simpler method of debugging outher than traceback
import win32ui, win32con

# example debug message to screen ......
# arcpy.AddMessage("mxd_file = " + str(mxd_file))
# val = win32ui.MessageBox("mxd_file = " + str(mxd_file), "title",


mxdList = string.split(arcpy.GetParameterAsText(0), ";")
dir = arcpy.GetParameterAsText(1)

#Loop thru & take the base name of each MXD selected and append all map pages to a single pdf
# and save to chosen directory......

for mxdPath in mxdList:
mxd = arcpy.mapping.MapDocument(mxdPath)
name = mxdPath[:-4] + ".pdf"
file = dir + os.sep + os.path.basename(name)
ddp = mxd
ddp.exportToPDF(file, "ALL")

del mxd, file