import arcpy, os, sys, string # Define parameter settings for the toolbox def getParameterInfo(self): #Define parameter definitions # First parameter param0 = arcpy.Parameter( displayName="Input MXD's", name="multimxds", datatype="DEMapDocument", parameterType="Required", direction="Input", multiValue=True) # Second parameter param1 = arcpy.Parameter( displayName="Output folder", name="outputfolder", datatype="DEFolder", parameterType="Required", direction="Output") # Third parameter param2 = arcpy.Parameter( displayName="PDF Resolution", name="pdfREs", datatype="GPLong", parameterType="Required", direction="Input") #overwirte existing PDFs arcpy.env.overwriteOutput = 1 multimxds = [filename for filename in string.split(arcpy.GetParameterAsText(0), ";")] outputfolder = arcpy.GetParameterAsText(1) pdfREs = arcpy.GetParameterAsText(2) pdfRES = str(pdfREs) teller = 0 # to be used for generating pdf file names when no mxd.title is specified #print multimxds #Create output folder if not os.path.exists(outputfolder): os.makedirs(outputfolder) #trying to set folder path folderpath = outputfolder #export to pdf #trying to export to pdf using title name and folder parameter try: for mxdloop in multimxds: mxd = arcpy.mapping.MapDocument(mxdloop) if mxd.title != "": name = mxd.title else: name = str(teller) pdf = folderpath + '\\' + name + ".pdf" if os.path.exists(pdf) == 'true': pdf = folderpath + '\\' + name + str(teller) + ".pdf" else: pdf = pdf print pdf # for debugging arcpy.mapping.ExportToPDF(mxd, pdf, data_frame="PAGE_LAYOUT", df_export_width="", df_export_height="", resolution=pdfRES) teller = teller+1 del mxd arcpy.AddMessage(pdf + "has been exported succesfully") print teller # for debugging except Exception as e: print e.message # If using this code within a script tool, AddError can be used to return messages # back to a script tool. If not, AddError will have no effect. arcpy.AddError(e.message) #Succes message in the end arcpy.AddMessage("Done exporting "+str(teller)+ " MXD's to PDF's in folder" + folderpath) #delete folderpath variable del folderpath
Even if I'm right, no doubt it's too little too late. You've given up or you already figured this out. However, casting your resolution as integer vs text is probably not the issue. Numeric values are passed in as strings all the time (i.e. arcpy.Buffer_analysis("roads", "C:/output/majorrdsBuffered", "100 Feet"...)). If units are left out (i.e. arcpy.Buffer_analysis("roads", "C:/output/majorrdsBuffered", "100")) the linear units of the input features' spatial reference are passed in.
What seems to be the issue is the declaration (or definition? I forget which...) of ' df_export_width="", df_export_height="" '. Why exactly, I'm not sure. However, if you're using "Page_Layout" as the declaration for the data_frame variable, you don't need to pass in df_export_width or height.
For example, this worked for me:
arcpy.mapping.ExportToPDF(map,"P:\\Proj6\\USNVC\\Range\\geoPdf\\" + field + "d.pdf","PAGE_LAYOUT",resolution = "75")
while this did not:
arcpy.mapping.ExportToPDF(map,"P:\\Proj6\\USNVC\\Range\\geoPdf\\" + field + "d.pdf","PAGE_LAYOUT",df_export_width="", df_export_height="",resolution = "75")
Notice that the resolution is passed in as a string in both.