Use of exportwebmap from printing toolset

646
2
Jump to solution
07-22-2019 11:43 AM
AyyazMahmood-Paracha
New Contributor III

Hello everyone,

I need one guidance regarding the utilsiation of task arcpy.ExportWebMap_server. 

I want to use this task in one of my geo processing synchrone service. During my unit testing, I publish the following geo processing service:

import arcpy

arcpy.env.workspace="/app/testprint"

WebMapAsJson = arcpy.GetParameter(0)
FormatPrint = arcpy.GetParameterAsText(1)
LayOutTemplate = arcpy.GetParameterAsText(2)
PrintName = arcpy.GetParameterAsText(3)
testPrintCommand = arcpy.ExportWebMap_server(Web_Map_as_JSON=WebMapAsJson, Output_File=PrintName, Format=FormatPrint, Layout_Templates_Folder="", Layout_Template=LayOutTemplate)

When I execute this code through Python installed on server, the code runs and generates a PNG in the folder /app/testprint without any error. Whereas when I publish the geo-processing service, the code returns me the output filename (\\app\testprint\<filename>.png) but no file is generated.

Can anyone please guide me, how can I can make this code works. Any guidance or clue will be useful for me. 

Thanks

0 Kudos
1 Solution

Accepted Solutions
AyyazMahmood-Paracha
New Contributor III

Hi Neil,

Unfortunatley not. I tried but did not find any solution. Then I implemented my print service through:

result = arcpy.mapping.ConvertWebMapToMapDocument(mapAsJson, templateMxd)
mxd = result.mapDocument

outputName = 'WebMap_{}'.format(str(uuid.uuid1()))
outputFile = os.path.join(arcpy.env.scratchFolder,outputName)
if fileFormatLower == 'pdf':
## arcpy.mapping.ExportToPDF(mxd, outputFile, resolution = int(dpi))
   arcpy.mapping.ExportToPDF(mxd,outputFile)
   outputFile = outputFile+".pdf"

So I had to implement for each format. I followed this documentation. ExportToPDF—Help | ArcGIS for Desktop 

Hopefully, it will help you

Ayyaz

View solution in original post

0 Kudos
2 Replies
NeilEtheridge
New Contributor III

Hi Ayyaz, Did you ever get to the bottom of this?  I'm having exactly the same problems.

Thanks,

Neil

0 Kudos
AyyazMahmood-Paracha
New Contributor III

Hi Neil,

Unfortunatley not. I tried but did not find any solution. Then I implemented my print service through:

result = arcpy.mapping.ConvertWebMapToMapDocument(mapAsJson, templateMxd)
mxd = result.mapDocument

outputName = 'WebMap_{}'.format(str(uuid.uuid1()))
outputFile = os.path.join(arcpy.env.scratchFolder,outputName)
if fileFormatLower == 'pdf':
## arcpy.mapping.ExportToPDF(mxd, outputFile, resolution = int(dpi))
   arcpy.mapping.ExportToPDF(mxd,outputFile)
   outputFile = outputFile+".pdf"

So I had to implement for each format. I followed this documentation. ExportToPDF—Help | ArcGIS for Desktop 

Hopefully, it will help you

Ayyaz

0 Kudos