Additional Service for web map printing that creates a file with specific name

1813
8
Jump to solution
02-20-2017 08:22 PM
PitersonPaulgek
New Contributor III

Hi,

We try to find way to create a file with specific name ("Test123.pdf") using additional service for printing on ArcGIS Server.

ArcGIS Server 10.4

Any help will be greatly appreciated.

0 Kudos
1 Solution

Accepted Solutions
FC_Basson
MVP Regular Contributor

I don't think that parameter option is available.  See the Export Web Map specifications and use the object model provided to add extra parameters.

I must admit, I played around with the export web map script and I could not get the GP service to save the file in the GP service's output folder, but it worked great if you specify another "managed" output folder on the server. E.g:

import arcpy

arcpy.env.workspace = r"\\gis-server\print\outputs"

json = arcpy.GetParameter(0)
name = arcpy.GetParameterAsText(1)

arcpy.ExportWebMap_server(json, name, "PDF", "", "MAP_ONLY")‍‍‍‍‍‍‍‍

View solution in original post

8 Replies
FC_Basson
MVP Regular Contributor

Do you want the file to be stored with that filename in the service directory or should the file be named like that for download for the user?

0 Kudos
PitersonPaulgek
New Contributor III

Thank you for your response, FC Basson.

We want the service saves the file on the server in directory

C:\arcgisserver\directories\arcgisjobs\OUR_EXPORT_SERVICENAME\Test123.pdf

Currently,

it saves in random directory with random name:

C:\arcgisserver\directories\arcgisjobs\OUR_EXPORT_SERVICENAME\jfcaa84301209481aaacf4b7aba400719\scratch\random_name.pdf

0 Kudos
FC_Basson
MVP Regular Contributor

It is definitely possible if you generate the map with arcpy e.g.

arcpy.ExportWebMap_server(webmapjsonstring,"TEST.PDF","PDF","","MAP_ONLY")

So maybe you can create your own ExportWebMap GP tool from a script and specify the output filename as an input parameter

PitersonPaulgek
New Contributor III

Can we call this script  from Javascript on the client?

0 Kudos
FC_Basson
MVP Regular Contributor

Yes, like a normal geoprocessing service.  You must obviously create and publish the script tool and you can set all the map options on the client side and just pass them as input parameters for the GP service.

PitersonPaulgek
New Contributor III

Thank you, FC Basson.

We already have a geoprocessing service, we can see the parameter "Output_File" in the ArcGIS REST Services Directory page for the print service.

How to use it? Do we use "extraParameters"?

PrintParameters | API Reference | ArcGIS API for JavaScript 3.19 

We tried to use it like

params.extraParameters = [{ "Output_File": "Test123.pdf"}];

0 Kudos
FC_Basson
MVP Regular Contributor

I don't think that parameter option is available.  See the Export Web Map specifications and use the object model provided to add extra parameters.

I must admit, I played around with the export web map script and I could not get the GP service to save the file in the GP service's output folder, but it worked great if you specify another "managed" output folder on the server. E.g:

import arcpy

arcpy.env.workspace = r"\\gis-server\print\outputs"

json = arcpy.GetParameter(0)
name = arcpy.GetParameterAsText(1)

arcpy.ExportWebMap_server(json, name, "PDF", "", "MAP_ONLY")‍‍‍‍‍‍‍‍
PitersonPaulgek
New Contributor III

Thank you, FC Basson.

0 Kudos