1

I have a script that is run on a daily basis to export a folder of MXDs to PDFs and I have noticed some peculiar behavior. Many, but not all of the PDFs will be missing some labels or their label orientation gets changed. These errors do not occur when I manually export from arcmap. In an attempt to isolate the problem, I wrote a code snippet to simply export a PDF and it behaved normally, no errors.

Is there a reason that stepping through a folder of MXDs would cause this error?

I have included the code below.

    import arcpy
    import os
    arcpy.env.workspace = r"\\fs1\shared\GIS\Map_Documents\NightlyUpdates"
    ws = arcpy.env.workspace
    outPDF = r"\\fs1\shared\GIS\Map_Documents\NightlyUpdates\PDF"
    MXDlist = arcpy.ListFiles("*.mxd")
    for MXD in MXDlist:
        root = os.path.splitext(MXD)[0]    
        title = '\\'+ root + ".pdf"
        tempMXD = arcpy.mapping.MapDocument(os.path.join(ws,MXD))
        arcpy.mapping.ExportToPDF(tempMXD, outPDF+title, image_quality="BETTER")
        del tempMXD
3

I was having a similar issue. When I switch the Parser on the label expression to JSCript the labels exported correctly.

  • Changing the label expression to VBScript worked for me. – Tom Dec 10 '15 at 22:46
  • Searched forever why my labels were disappearing. Both JScript and VBScript work for me, whereas python did not as soon as I started adjusting colors. This answer saved me a lot of hassle, although I still have no idea why the labels do not appear when using the python parser and arcpy (they are perfectly fine in arcmap itself). – JiyuuSensei May 4 '17 at 6:35
0

Are the map extents the same when exporting manually from Arcmap as they are exporting using arcpy? Slight differences in extent can have knock-on effects across the map resulting in some labels being placed differently or removed.

It might be a good idea to zoom to a bookmark before exporting, or use layout view so the extent is the same every time.

  • The map extents should not be changed when exporting from arcpy. I believe the error is occurring on the server. For this reason I have started a new question. Thank you for your input. – Andrew Mar 16 '15 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.