1

I've created a simple python toolbox (pyt) to export map layouts to multiple formats. My problem is that some labels which are defined in the layout are exported, but others are not. For example point labels export but contour labels dont. When I export from within ArcMap all labels are exported.

Question: Is there any argument missing from my "arcpy.mapping.Export" statements that would affect labeling?

I had problems posting the whole toolbox but it can be downloaded from here: Export MXD Toolbox

Here's the code that does the exporting.

# mxd name
mxd = arcpy.mapping.MapDocument(parameters[1].valueAsText)
# workspace
env.workspace = parameters[0].valueAsText
# workspace text to use in paths
workSpace = parameters[0].valueAsText
AddMessage("The workspace is " + env.workspace)

# resolution
dpi = parameters[2].valueAsText
# filename
name = parameters[3].valueAsText
# option for formats to export
createPDF = parameters[4].valueAsText
createTIFF = parameters[5].valueAsText
createEPS = parameters[6].valueAsText
createAi = parameters[7].valueAsText

# Export PDF
if createPDF == "true":
  AddMessage("Exporting PDF")
  arcpy.mapping.ExportToPDF(map_document = mxd, out_pdf = workSpace + "\\" + name + ".pdf", resolution=dpi,
           convert_markers=True, layers_attributes="LAYERS_AND_ATTRIBUTES")
else:
  AddMessage("You chose not to create a PDF")

# Export TIFF
if createTIFF == "true":
  AddMessage("Exporting TIFF")
  arcpy.mapping.ExportToTIFF(map_document = mxd, out_tiff = workSpace + "\\" + name + ".tif", resolution=dpi, tiff_compression="LZW")
else:
  AddMessage("You chose not to create a TIFF")

# Export EPS
if createEPS == "true":
  AddMessage("Exporting EPS")
  arcpy.mapping.ExportToEPS(map_document = mxd, out_eps = workSpace + "\\" + name + ".eps", resolution=dpi, image_quality="BEST",
           picture_symbol="VECTORIZE_BITMAP", convert_markers=True)
else:
  AddMessage("You chose not to create an EPS")

# Export to Ai
if createAi == "true":
  AddMessage("Exporting Ai")
  arcpy.mapping.ExportToAI(map_document = mxd, out_ai = workSpace + "\\" + name + ".ai", resolution=dpi, picture_symbol="VECTORIZE_BITMAP",
           convert_markers=True)
else:
  AddMessage("You chose not to create an Ai")
4
  • 1
    Welcome to gis.SE. What, in particular, would you like to ask. There is nothing in your question that ends with a question mark. Can you click edit below your question to update it with a specific answerable question?
    – BradHards
    Commented Feb 13, 2014 at 2:25
  • 1
    What results do you get if you just export the layout manually? Do all of the labels you want show in the PDF/TIF/AI/EPS?
    – Fezter
    Commented Feb 13, 2014 at 3:00
  • Yes, when I export manually all the labels show in all formats. Commented Feb 13, 2014 at 20:31
  • Did you ever find a solution to this? I am also having a problem with ExportToPDF. When I manually export from arcmap, the output is what I expect. When using a script to export, some labels go missing or their orientation is not correct. My script steps through a folder of MXDs. I wrote a snippet to test just the ExportToPDF on a single MXD and it works like expected. Any ideas why labels would go missing when using a loop to export multiple PDFs?
    – Andrew
    Commented Mar 13, 2015 at 21:34

1 Answer 1

2

Though it may not be the cause in your case, setting a label expression to use the Python parser can cause labels to be omitted from maps that are exported via code. It's just some wacky bug as far I can gather. Using VBScript or JSCript parsers for label expressions resolves the issue. See the link, below, for syntax for each of the parsers:

http://resources.arcgis.com/en/help/main/10.2/index.html#/Building_label_expressions/00s800000027000000/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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