TextElement with arcpy.mapping.ExportToJPEG

560
2
01-07-2019 03:36 AM
MicheleDe_Santis
New Contributor

Hi to all,

I'm using arcpy to export map in JPEG format. I am not able to get the TextElement in the output file. The label "Confini comunali" doesn't appear in the JPEG file. Even if I don't change TextElement.text, it doesn't work.

Can anyone help me?

Thank you,

 Michele

 PS Using ArcMap 10.1 on Windows 10, Python 32-bit.

 

The portion of my script is:

mxd = arcpy.mapping.MapDocument(r"C:\StampeGriglie\Comuni.mxd")
df = arcpy.mapping.ListDataFrames(mxd)[0]


# Change text element
TextElement = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "MioTesto")[0]
TextElement.text = "Confini comunali"

path_output = "C:/StampeGriglie/Output/1234.jpg"
arcpy.mapping.ExportToJPEG(mxd, path_output, df,
                           df_export_width=9360,
                           df_export_height=6623,
                           resolution=200,
                           world_file=False)
del mxd


0 Kudos
2 Replies
RandyBurton
MVP Alum

Although I am not running 10.1, I did some experimenting and have the following suggestion:

arcpy.mapping.ExportToJPEG(mxd, path_output, "PAGE_LAYOUT",
                           df_export_width=9360,
                           df_export_height=6623,
                           resolution=200,
                           world_file=False)

I am assuming the text element was created in layout view.  Referencing "df" in the export would point to the first data frame and not the layout view.

0 Kudos
MicheleDe_Santis
New Contributor

Hi Randy,

excuse me for the delay. You are right. I had to change dinamically the

TextElement, then I had to save mxd and now ExportToJPEG using

"PAGE_LAYOUT". It works.

Thanks

Michele

Il 8 gennaio 2019 alle 4.47 Randy Burton <geonet@esri.com> ha scritto:

GeoNet <https://community.esri.com/?et=watches.email.thread>

Re: TextElement with arcpy.mapping.ExportToJPEG

reply from Randy Burton

<https://community.esri.com/people/rvburton?et=watches.email.thread> in

Python - View the full discussion

<https://community.esri.com/message/823200-re-textelement-with-arcpymappingexporttojpeg?commentID=823200&et=watches.email.thread#comment-823200>

0 Kudos