Print Task doesn't bring any result back

2705
6
Jump to solution
05-03-2016 10:38 AM
IsraAlhamood
New Contributor II

Hello everyone,

I'm trying to have a print widget in my application. I'm using PrintTask.  here's the code:

  var template = new PrintTemplate();

            template.exportOptions = {

                width: 500,

                height: 400,

                dpi: 96

            };

            template.format = "PDF";

            template.layout = "MAP_ONLY";

            template.preserveScale = false;

            params = new PrintParameters();

            params.map = map;

            params.template = template;

            params.outSpatialReference = map.spatialReference;

         

            printTask = new PrintTask('url', { async: true });

And then whenever the user clicks on the print button it will go to the following function

function print() {

            printTask.execute(params, printResult, printError);

         

        }

           

      

function printResult(result) {

          

               window.open(results.value.url, "_blank");

        }

        function printError(result) {

            alert(result);

        }

When I run the application and click on print, it doesn't do anything(doesn't bring an error either)

anyone can help please? I would really appreciate it.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Isra,

  No the error will not give specifics, it will just be what you see esriJobFailed by default. You will need to go to your ArcGIS Server logs to find more detail on why it is failing.

View solution in original post

0 Kudos
6 Replies
JeffJacobson
Occasional Contributor III

The first thing I would try is to open the web developer tools in either Chrome or Firefox (press F12) and open the network tab before clicking the print button.

After clicking the print button, to you see calls to the print service? If you see no activity there then the problem is with the button event (e.g., the call to the print service is never occurring when the button is clicked).

0 Kudos
IsraAlhamood
New Contributor II

Jeff,

I see a lot of calls to the print service. But no results back whatsoever, wether it's an error or a PDF.

When I clicked on one of the first calls in the network tab and then go to the response body, the jobStatus is: esriJobExecuting and then when I see the last calls it says it's esriJobFailed.

But it doesn't say why! It's supposed to bring an error message when it catches an error.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Isra,

  No the error will not give specifics, it will just be what you see esriJobFailed by default. You will need to go to your ArcGIS Server logs to find more detail on why it is failing.

0 Kudos
JeffJacobson
Occasional Contributor III

You'll need to change the value of the Show Messages setting of the Print GP service if you want the service to return error messages to the client. (For security reasons, no messages are returned by default.)

YueWu1
by Esri Regular Contributor
Esri Regular Contributor

Hi Isra,

Is your print service is public facing or just intranet?

Why don't you try this print sample to see if you can print using your service:

Print templates with esri.request | ArcGIS API for JavaScript

Then using the developer tool from browser to compare the difference behavior from the sample print service versus yours.

Also, I would recommend read this thread to see if you have the similar issue Print Task doesn't bring any result back

0 Kudos
CraigMiller2
New Contributor

Your printResults function signature is printResult(result), but you reference it as results (plural) when retrieving the url to open the other window.

0 Kudos