Select to view content in your preferred language

Python script to export layout to JPG

5564
5
Jump to solution
11-05-2021 08:22 AM
LindaSlattery
Regular Contributor

I am trying to find a script that exports my layout in ArcPro to a JPG once a week. Most of what I have found when searching has been for map series. Can anyone assist? Thanks!

1 Solution

Accepted Solutions
DominicRoberge2
Frequent Contributor

Hi Linda

would this works for you?

import arcpy

docPath = r"D:\FOLDER"
docName = r"AGSPRODOC.aprx"
p = arcpy.mp.ArcGISProject(docPath+"\\"+docName)
# ge a list of all layouts in your map dox
lLayout = p.listLayouts()
for l in lLayout:
    print(l.name)
    #You could add an if statement to print ONLY a specific layout
    l.exportToJPEG(docPath+"\\"+l.name+"jpg")

print("Process Completed")

View solution in original post

5 Replies
JoeBorgione
MVP Emeritus

This help page seems to imply you can just export a single layout to just about whatever image format you like. The arcpy.mp module does takes a little getting used to.

That should just about do it....
DominicRoberge2
Frequent Contributor

Hi Linda

would this works for you?

import arcpy

docPath = r"D:\FOLDER"
docName = r"AGSPRODOC.aprx"
p = arcpy.mp.ArcGISProject(docPath+"\\"+docName)
# ge a list of all layouts in your map dox
lLayout = p.listLayouts()
for l in lLayout:
    print(l.name)
    #You could add an if statement to print ONLY a specific layout
    l.exportToJPEG(docPath+"\\"+l.name+"jpg")

print("Process Completed")
LindaSlattery
Regular Contributor

@DominicRoberge2 , this works great! Thank you! However, one thing it is not doing is including my dynamic text that I have in the layout. I have a date/time exported and a record count. Any idea how to get the print command to include those?

0 Kudos
DominicRoberge2
Frequent Contributor

hummm I am not sure. it's working for me (see image below). Can you try to add a new dynamic txt for the count just for fun.

 

 

DominicRoberge2_0-1636383498020.png

 

LindaSlattery
Regular Contributor

Thanks! That worked!!! Much appreciated! 

0 Kudos