PDF output from Geoprocessing service

1979
8
08-25-2017 01:14 PM
AllenScully
Occasional Contributor II

We have created a geoprocessing service that uses a modified version the Reportlab pdf generation from the ESRI Public Notification app.  The script takes an address or  parcel, buffers it, generates 1 pdf for property owners in the buffer area, and a 2nd pdf for the Neighborhood Associations officers for the NHA where the parcel is.  

The script runs as desired, and generates the output pdf's in the scratch directory on the ArcServer machine (C:\users\username\documents\ArcGIS\Scratch).

My issue is that when creating a web app with a Geoprocessing Widget that uses the script published as a service, I don't know where the output goes.  It runs successfully, but the output remains out of reach.  The Public Notification application opens a new browser tab with the PDF mailing label output - I would like to have the same behavior with my custom script but am not sure how to set this up.  

The output_file variable is actually part of a list so that the script can loop through to generate the owner and NHA pdf's as separate files, but it is currently coded as follows:

   labellst = [[arcpy.GetParameterAsText(5).replace("\\",os.sep)+"owners.pdf","parc"],
                   [arcpy.GetParameterAsText(5).replace("\\",os.sep)+"nha.pdf","neigh"]]  

The script has the output file as a derived 'output' parameter of type 'file'.

Thanks -

Allen

0 Kudos
8 Replies
RebeccaStrauch__GISP
MVP Esteemed Contributor

I'm not 100%, but have you check to see if it is in the download folder of the client machine??

If that is not the case, I will look to see how we did it with our print GP tool...maybe it will be similar.  (I recall creating a folder where the output was written and I think including it in a CORS file for the IIS machine...but just guessing from memory since it was a couple years ago I set it up)

edit:  tagging https://community.esri.com/community/gis/enterprise-gis/arcgis-for-server?sr=search&searchId=0bd875e...‌  https://community.esri.com/community/gis/analysis/geoprocessing?sr=search&searchId=1060c4f9-9a93-46b...

ClintonDow1
Occasional Contributor II

If the service is working as expected, its derived outputs should end up at an endpoint like: http://[nameofserver]/ArcGIS/rest/services/[NameOfGPToolBox]/GPServer/[NameOfGPScript]/jobs/[job-id]...

For a fully featured web application, you'd want to handle that URL and provide the user with a means of downloading from that location and 'hide' that url from the end user. For example a redirect to the download link, a button they can click on the website or something like that.

AllenScully
Occasional Contributor II

Thanks Clinton and Rebecca -

I do get a link similar to what Clinton describes - however clicking it gives an Invalid URL 400 message. I believe the reason is related to the fact that the script has a little wrinkle in it, in that it loops through and generates 2 output pdfs, with the names being passed into the label-generation function in python.  The link that does get generated is the generic one configured in the published version of the script, so it doesn't appear to be getting either of the names that it should be from the script variables.

0 Kudos
RebeccaStrauch__GISP
MVP Esteemed Contributor

I don't know that this will help at all, but my print pdf GP services creates a folder on my ags server in the folder:

 d:\arcgisserver\directories\arcgisjobs\print\myprint_gpserver\<longAlphaNumericString>

with a scratch.gdb (?) and status.cache, disappears almost immediately (fairly simple map) and then creates a file  _ags_<SAMElongAlphaNumericString>.pdf  in my clients c:\Users\<user>\AppData\Local\Temp\ folder and opens it up in Adobe.

It may show up with temp files other places too, but disappears to fast, hard to tell.  It seems to me I tried to specify a logical output name too (ie <hunt>.pdf), but it just ignored it.  I do not use a list, but print one request at a time.

If you want to see what the client see for our print pdf Alaska Hunting Maps by Species, Alaska Department of Fish and Game  click on one of the custom maps, and there is a print button there.

AllenScully
Occasional Contributor II

Thanks! Found it in the AGS jobs directory - now I have something to work with.  Hadn't thought to look in those directories.

0 Kudos
JamalWest2
Occasional Contributor

I have something similar with a pdf being written to the server from a GP service. How can I access and use the resulting url for the pdf so clients may download or view it?

0 Kudos
AllenScully
Occasional Contributor II

Figured this out with a little help from ESRI - here's the syntax used in the python script the says what the output path of generated pdf's will be:

os.path.join(arcpy.env.scratchFolder + r"\filename.pdf")

When the script is published as a geoprocessing service, a url is generated that successfully opens the pdf for printing/download.

Thanks all for the input.

JamalWest2
Occasional Contributor

Can you tell me how to retrieve and use this url for printing/downloading? I 've been trying to figure this out for awhile now. I have my geoprocessing service creating a pdf that saves on my server. I need to know how to determine the url and utilize it so the pdf can be accessed by the client side.

0 Kudos