ArcPro Layout won't print when served as geoprocessing service

373
2
01-10-2023 05:15 PM
FredSpataro
Occasional Contributor III

Hello All, 

We have a cool little geoprocessing analysis script that creates some data, does a bit of analysis and generates an awesome pdf 😉 .... this script works great when run from a desktop toolbox.  When we publish it to server to connect to a web application, it fails at the point where we open the layout (pagx).  There's no error message, the job just seems to die.  Nothing in the AGS logs after a certain point when setting log level = debug.  All the data and analysis artifacts (charts, csvs) get created fine -- i can inspect them in the AGS jobs folder.  It's definitely in the final manipulation and export of the layout.  

We've done this before with ArcMap mxds and this is the first attempt with Pro aprx/pagx so maybe I'm just missing a crucial step in the process of opening the layout.

I've distilled out all the fun data analysis and made a simple layout with a single text element for the title and a single map with only the stock basemap... no custom data, no fancy other elements... still dies in the same manner.   

I took out the map, so the layout has only a text element which the script/service will modify when run to ensure something is running dynamically and it works.  So it seems like something with the map/map frame is the issue.  Is there a 'activate' or 'update' map needed? 

Setup: ArcPro 2.9.5 / ArcGIS Server (standalone) 10.9.1

Here's the guts of the "run" method in the simplified script.  Any thoughts would be greatly appreciated

def ScriptTool(input_templates_folder, input_cool_text):
    analysis_folder = arcpy.env.scratchFolder
    map_template = os.path.join(input_templates_folder, 'Layout3.pagx')
    arcpy.AddMessage('Template PAGX: {}'.format(map_template))
    analysis_template = os.path.join(analysis_folder,'Layout3.pagx' )
    arcpy.AddMessage('Analysis PAGX: {}'.format(analysis_template))
    shutil.copyfile(map_template, analysis_template)
    arcpy.AddMessage('Analysis PAGX: copied')
    lyt = arcpy.mp.ConvertLayoutFileToLayout(analysis_template)
    arcpy.AddMessage('Analysis PAGX: opened')
    txt = lyt.listElements('TEXT_ELEMENT', 'Text')[0]
    arcpy.AddMessage('Analysis PAGX: element found')
    txt.text = input_cool_text
    arcpy.AddMessage('Analysis PAGX: element updated')
    layout_pdf = os.path.join(analysis_folder, "layout.pdf")
    arcpy.AddMessage('Analysis PAGX: exporting to {}'.format(layout_pdf))
    lyt.exportToPDF(layout_pdf)
    arcpy.AddMessage('Analysis PAGX: complete')
    return layout_pdf

 

0 Kudos
2 Replies
by Anonymous User
Not applicable

I'd check your licensing and see if it is correct for either the server user account or for offline use. Pro licenses arcpy so it may not be activating when you are signed out of the app.

0 Kudos
FredSpataro
Occasional Contributor III

Hi @Anonymous User,

Is there documentation on 'licensing' arcpro inside ArcGIS Server?  I have an full ArcGIS Server Advanced license on this machine.    What other license or setup is required?

Also the script runs has expected when I execute it at the command line using the python env embedded in the ArcGIS server installation directory ... ArcPro app is not even running at that point so it doesn't seem like a licensing issue to me but possibily

0 Kudos