jaybo684

Invalid MXD filename error

Discussion created by jaybo684 on Mar 14, 2011
Latest reply on Mar 28, 2013 by TASurvey100
I'm trying to modify a python script that was provided by Esri in the sample arcpay mapping script tools. I'd like to export a PDF for each MXD selected instead of exporting multiple MXDs to a single PDF. Below is the Esri version and beneath that is my version. I feel like I'm doing everything right, but obviously I'm missing something. Any guidance is greatly appreciated.

# Author:  ESRI
# Date:    July 5, 2010
# Version: ArcGIS 10.0
# Purpose: This script will export multiple map document layoutinto a single
#          output PDF file. The script is intended to run within a script tool.  There are two
#          parameters:
#               1) Select Map Documents to Append,
#               2) Output PDF.
#
#Notes: The order of the MXDs is based on how they are entered.  The MXD at the
#       top of the list is first followed by those below it.

import arcpy, os, string

#Read input parameters from script tool
mxdList = string.split(arcpy.GetParameterAsText(0), ";")
outPDFpath = arcpy.GetParameterAsText(1)

#Create a new PDF object to store the results
outputPDF = arcpy.mapping.PDFDocumentCreate(outPDFpath)

#Loop through each MXD in the list, export, create a temporary PDF name,
# and append to final, output PDF
for mxdPath in mxdList:
    mxd = arcpy.mapping.MapDocument(mxdPath)
    PDFPath = mxdPath[:-4] + "_temp.pdf"
    arcpy.mapping.ExportToPDF(mxd, PDFPath)
    outputPDF.appendPages(str(PDFPath))


#Save the changes and open the result automatically   
outputPDF.saveAndClose()
os.startfile(outPDFpath)

#Remove variable reference to file
del outputPDF


#MY CODE
import arcpy, os, sys, string

#overwirte existing PDFs
arcpy.OverWriteOutput = 1

multimxds = string.split(arcpy.GetParameterAsText(0), ";")
outputfolder = arcpy.GetParameterAsText(1)

#set variable for PDF name
#trying to set folder path
folderpath = outputfolder

#export to pdf
#trying to export to pdf using title name and folder parameter
for mxdloop in multimxds:
    mxd = arcpy.mapping.MapDocument(mxdloop)
    name = mxd.title
    pdf = folderpath + '\\' + name + ".pdf"
    arcpy.mapping.ExportToPDF(mxd, pdf, 'PAGE_LAYOUT', 640, 480, 400)

#delete folderpath variable
del folderpath

Outcomes