I am trying to use printTask as shown below, but it's not going in the printResult function.
function printImage() {
var printTask;
var params = new PrintParameters();
if (sentScale == 1000) {
printTask = new PrintTask('http://10.10.100.50:6080/arcgis/rest/services/karpos/Print_Karpos/GPServer/Export%20Web%20Map');
params.map = map;
}
else if (sentScale == 2500) {
printTask = new PrintTask('http://10.10.100.50:6080/arcgis/rest/services/karpos/Print_Karpos/GPServer/Export%20Web%20Map');
params.map = map;
}
var template = new PrintTemplate();
template.format = 'JPG';
template.layout = 'MAP_ONLY';
template.preserveScale = false;
params.template = template;
console.log("params", params)
//printTask.execute(params).then(printResult);
printTask.execute(params, printResult);
}
// PRINT IMAGE
// PRINT RESULT
function printResult(evt) {
imageUrl = evt.url;
setCookie('imageUrl', imageUrl, 1);
if (reportType == 1) {
printReport();
}
if (reportType == 2) {
console.log("reporttype2 start")
var printTaskLegend;
var printPars = new PrintParameters();
printPars.map = map;
if (sentScale == 1000) {
console.log("reporttype2 1000")
printTaskLegend = new PrintTask('http://10.10.100.50:6080/arcgis/rest/services/karpos/Print_Karpos/GPServer/Export%20Web%20Map');
printPars.map = map;
}
else if (sentScale == 2500) {
console.log("reporttype2 2500")
printTaskLegend = new PrintTask('http://10.10.100.50:6080/arcgis/rest/services/karpos/Print_Karpos/GPServer/Export%20Web%20Map');
printPars.map = map;
}
var template = new PrintTemplate();
template.format = 'JPG';
template.layout = 'Print_legend_included';
template.preserveScale = true;
printPars.template = template;
printTaskLegend.execute(printPars, printImageLegend);
//printTaskLegend.execute(printPars).then(printImageLegend);
console.log("reporttype2 end")
}
}
I am printing out the params with console.log in printImage and according to this, I think it ok?
I tried to use both printTask.execute(params).then(printResult); as well as printTask.execute(params, printResult);
but it just does not go into printResult. Anyone has any idea why?
Hi novica.josifovskigdi-net-esridist
Does the network show the request being passed when you call the print if not then it potentially is unable to reach the printResult function.
What I can suggest you is you can try to modify you code as below:
printTask.execute(params, function(evt){
//code snippet from your printResult function goes here....
});
Suspect the print execute is unable to reach to the function.
Cheers,
Manish
I would try catching a potential error with this format:
printTask.execute(params).then(printResult, printError);
And here it is in action: