I'm using a python script to export a set of maps created with ArcMap's Data Driven Pages (DDP). Everything was working well until I added a new layer to the map - it automatically added to the legend, which I didn't want, so I removed it. Ever since then, however, the legend has been re-sizing at random during export.

It's not an overwrite issue (I'm removing all images from the target folder before running the script) and I've tried deleting and re-creating the legend, which has caused fewer of the maps to have re-sized legends, but there are still some. I'm not sure what to try next, or what caused this in the first place.

Here's my script (modified from Changing output name when exporting data driven pages to JPG?):

# Modify the directory to match your file locations
import_path_Singles = r"C:\Users\Keegan\Desktop\14Feb2017_RVCAmapping\Arc_v10_3\RMP_Ag_SinglePlates.mxd"

# The script will then generate output JPG files at a specified out-path:
export_path = r"C:\Users\Keegan\Desktop\14Feb2017_RVCAmapping\Arc_v10_3\OutputJPGs"

# Then specify a "sort" field
field_name = "ASSESSMENT_ROLL_NUMBER" # Name of field used to sort DDP
#field_name = "Assessment Roll Number"
print field_name

import arcpy 
mxd = arcpy.mapping.MapDocument(import_path_Singles)
print mxd.dataDrivenPages.getPageIDFromName(field_name)
for i in range(1, mxd.dataDrivenPages.pageCount + 1):
    mxd.dataDrivenPages.currentPageID = i
    row = mxd.dataDrivenPages.pageRow
    arcpy.mapping.ExportToJPEG(mxd, export_path + "\\" + row.getValue(field_name) + "SinglePlate.jpg")
del mxd

The results can be seen in the image below - at left, good legend, at right, bad legend:

Left: Good legend. Right: Bad legend.

In Layout view, the legend looks like the one at left, and of the 21 maps I'm generating, some look like that one, and some look like the one at right.

Has anyone come across this before? Any idea what's going on here, and how to fix it?

closed as off-topic by PolyGeo Apr 23 '17 at 11:16

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This problem cannot or can no longer be reproduced. Changes to the system or to the asker's circumstances may have rendered the question obsolete, or the question does not include a procedure to enable potential answerers to reproduce the same symptoms. Such questions are off-topic as they are unlikely to help future readers, but editing them to include more details can lead to re-opening." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.