Back in 2008 when writing a batch export mxd to PDF tool using VBA, I noticed the tool will eventually crash ArcMap when run on a large number of maps (depending on complexity, it may take ~30 to ~60 maps that we deal with on a daily basis). In addition, graphic elements stored in the mxd instead of a feature class sometimes were not exported.
Here is the response from ESRI regarding the crash part from 2008:
"...
the reason behind the error, you are getting in ArcMap is because of a GDI Object leak in exportPDF class. There is a limit to the number of GDI Objects a running process in Windows can create..."
With the new mapping module of arcpy, I tested the below Python scripts, given its simplicity over an Add-in. To my disappointment, the scripts crashed ArcMap after exporting 90 some maps. The problem of some mxd graphic elements not exporting was observed as well. Does anyone know if this is still a problem of the underlying ArcObjects, or I am missing something here? Thanks a lot!
I tried to send in the error report, but it failed twice in a row. I'm attaching it here in case any ESRI rep will look at this post.
[scripts:]
import arcpy
import os
import string
mxdFileList=string.split(arcpy.GetParameterAsText(0), ";")
pdfPath=arcpy.GetParameterAsText(1)
for mxdFile in mxdFileList:
mxdFileBname=os.path.basename(mxdFile)
pdfFile=pdfPath+"\\"+os.path.splitext(mxdFileBname)[0] + ".pdf"
arcpy.AddMessage("Exporting "+ pdfFile+" ...")
mxd = arcpy.mapping.MapDocument(mxdFile)
arcpy.mapping.ExportToPDF(mxd, pdfFile)
del mxd