map-tools-template icon indicating copy to clipboard operation
map-tools-template copied to clipboard

Print task doesn't download PDF

Open crackernutter opened this issue 10 years ago • 4 comments

I'm using this template with an ArcGIS for Portal 10.3 Web Map. The template is hosted on a web server (not within Portal for ArcGIS). The print task executes successfully using our internal Export Web Map Task - if I check response in the Chrome console, I can see the uri for the resultant pdf (ie, https://ourgisserver.domain.com/arcgis/rest/directories/arcgisoutput/Utilities/PrintingTools_GPServer/_ags_a9f6356224014f44bd08ed32495ff169.pdf).
However, the app doesn't automatically download the pdf. At some point in the JS, window.location would have to be set to the uri for the pdf but that doesn't seem to happen. Any suggestions?

crackernutter avatar Sep 28 '15 16:09 crackernutter

When using your own print service, is there any other place in the template where you need to specify parameters? I plugged in our printTask URL in the defaults.js file, but the web map is still calling the Esri default printTask.

GISTiger avatar Jul 12 '16 14:07 GISTiger

@crackernutter you should see a printout link appearing in the print dialog after the print operation finishes executing. Click on the printout link and the pdf will open in a new window.

@GISTiger we need to do a better job of documenting this but here's what you need to do. First you'll want to set all the helper services used by the app (geometry, print, geocode) in defaults.js then in templateConfig.js set queryForOrg to false.

  "helperServices": {
    "geometry": {
      "url": "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer"
    },
    "printTask": {
      "url": "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"
    },
    "elevationSync": {
      "url": null
    },
    "geocode": [{
      "url": "http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"
    }]

Another option would be to find the code that creates the Print widget (~ line 543 of main.js) and replace the this.config.helperServices.printTask.url with the url to your print service.

kellyhutchins avatar Jul 12 '16 16:07 kellyhutchins

@kellyhutchins - Thanks, I found that queryForOrg parameter, and setting it to false fixed the problem. Are you aware of any further documentation on customizing print services besides the basic tutorial? Our custom print service does not behave the same way that the default one does (it tries to open the map in a new tab using http protocol, and I need it to provide the Printout link with https protocol). Online documentation on print services seems really limited.

GISTiger avatar Jul 12 '16 16:07 GISTiger

When you set the print url make sure you specify https instead of http. If your service supports https that should resolve the problem. The ArcGIS Server doc might have more info. http://server.arcgis.com/en/server/latest/create-web-apps/windows/printing-in-web-applications.htm#ESRI_SECTION1_837385C614A84A05B2F1BAD5949ACCF2

kellyhutchins avatar Jul 12 '16 16:07 kellyhutchins