joe.nunn@landuse.co.uk

ExportToPDF Batch

Discussion created by joe.nunn@landuse.co.uk on Jul 19, 2011
Latest reply on Jul 19, 2011 by joe.nunn@landuse.co.uk
Hi - done a script to batch process multiple MXDs and I get this error:
Runtime error <type 'exceptions.AttributeError'>: PageLayoutObject: Error in executing ExportToPDF

The error seems to be due to the PDF string 'pdfname' as if I put r'C:\\temp\\test.pdf') directly in the ExportToPDF function (not in the string though!) it works. Whats the problem?

Here is the script:

import glob, arcpy, os

mxdlist = glob.glob('T:\\45\\4588 EIA (London)\\Graphics\\GrDOCS\\Reports_5211\\ES\\*.mxd')

for mxd in mxdlist:
    m = os.path.basename(mxd)
    basename, ext = os.path.splitext(m)
    mxdproper = arcpy.mapping.MapDocument(mxd)
    print mxd
    print basename
    pdfname =  r"%s%s%s" % (r"T:\\45\\4588 EIA(London)\\Graphics\\GrDOCS\\Reports_5211\\ES\\",basename, r".pdf")
    print pdfname
    arcpy.mapping.ExportToPDF(mxdproper, pdfname)
    del mxd

Outcomes