I would like to be able to update a load of pdf and jgeg maps once the data has been updated. Currently people have to open each mxd and export the map in each format. I've written a short python script that will export the current mxd. This works well:
##export current mxd to pdf and jpeg
mxd = arcpy.mapping.MapDocument("CURRENT")
mxd.save()
filename = mxd.filePath.split("\\")[-1].split(".")[0]
path = '\\\\main.corp.local\\E-GB$\\Home\\4\\J042\\Documents\\PWISE' + "\\" +filename
arcpy.mapping.ExportToPDF(mxd, path + '.pdf')
arcpy.mapping.ExportToJPEG(mxd, path + '.jpg',"PAGE_LAYOUT", 400,500,300)
This doesnt save all that much time though because someone still needs to open all the mxds and run it. I've therefore written this to run on each mxd:
##export current mxd to pdf and jpeg
import arcpy, os
#mxd = arcpy.mapping.MapDocument("CURRENT")
for root, dirs, files in os.walk(r"\\main.glb.corp.local\EP-GB$\Home\ABZ\4\J0422414\Desktop\EXPORTMXD"):
for f in files:
if f.endswith(".mxd"):
mxdfile = root + '\\' + f
mxd = arcpy.mapping.MapDocument(mxdfile)
mxd.save()
filename = mxd.filePath.split("\\")[-1].split(".")[0]
path = '\\\\main.corp.local\\E-GB$\\Home\\4\\J042\\Documents\\PWISE' + "\\" +filename
arcpy.mapping.ExportToPDF(mxd, path + '.pdf')
arcpy.mapping.ExportToJPEG(mxd, path + '.jpg',"PAGE_LAYOUT", 400,500,300)
else:
print f
The weird problem here is that when there is a table in the layout view of the lap (as in attribute table menu > Add Table to Layout) it will not show - there is just a white space. This problem occurs both on the pdf and the jpeg
Does anyone know either if there is a solution to this export bug, or if I can adjust my script to open and close each mxd, running the relevant part of the script from within it? because it seems to work if the mxd is open