Good morning! I am using ARCGIS Pro v2.3 to develop a web tool, part of which exports pdf to a created directory on our server. While the script runs perfectly in arcgis Pro, when I publish it as a web tool I receive OS Error: (path.) This error occurs on the line lyt.ExportToPDF (path.) The path is dynamic, in the sense that a new folder is created in the directory each time, and changes each time the script is run. Additionally, I am able to write other files to the path, just not the pdf. I have tried changing paths, taking away transparency on the maps themselves, creating the pdf document before the output, etc. I am just so lost on this and would love some help/ideas. It makes no sense to me as well because the script runs perfectly up until I publish it as a web tool. Thanks!
Yes, the parent directory is registered and I believe it is a drive mapped path (though I am fairly new in this area so am not entirely sure.) I am unable to share the full script, but here are the parts I can share were it errors at
output_workspace = arcpy.GetParameterAsText(0) #folder
geodatabase_name = arcpy.GetParameterAsText(1) #string
os.mkdir(output_workspace + '//' + geodatabase_name)
output_workspace = output_workspace + '//' + geodatabase_name
def create_new_constraints_pdf(output_workspace, geodatabase_name, output_geodatabase):
aprx = arcpy.mp.ArcGISProject(path to aprx) #aprx gets copied to web tool
arcpy.env.workspace = output_geodatabase
map = aprx.listMaps()
constraints_lyr = output_workspace + '//' + 'constraints' + '.Lyrx'
lyrFile = arcpy.mp.LayerFile(constraints_lyr)
lyt = aprx.listLayouts()
legend = lyt.listElements("LEGEND_ELEMENT") #Calls Legend Element
legend.syncNewLayer = True #Makes all newly added layers appear in legend
for lyr in map.listLayers(): #For statement will properly color layers on map
sym = lyr.symbology
if hasattr(sym, 'renderer'):
if sym.renderer.type == 'SimpleRenderer':
sym.renderer.classificationField = "total_score"
sym.renderer.breakCount = 5
lyr.symbology = sym
lyr = map.listLayers()
lyr.transparency = 20 #Sets transparency to 20%
legend.syncLayerVisibility = True #Places all layers on map into legend
lyt.exportToPDF(output_workspace + '//' + 'transparent') #(Errors out here)
try an os.path.join instead of concatenation on
lyt.exportToPDF(output_workspace + '//' + 'transparent')
also are you missing the .pdf in the filename?
The syntax highlighter would make this much more readable to others.