Hi
Below is the code I am using it for Print the Map . The code works fine and got the output as PDF file in separate window.
But the issue is map extent in the application and map extent in PDF output are not matching exactly. "Image1" is from WAB application and "Image2" is from PDF out put . Kindly refer the attached Image for reference.
var url = "https://servername/gis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task";
var printTask = new PrintTask(url);
var params = new PrintParameters();
var template = new PrintTemplate();
template.format = "PDF";
template.layout = "MAP_ONLY";
template.layoutOptions = {"legendLayers": [legendLayers],
"titleText": "Map Print",
"authorText": "AAAAAAAA",
"copyrightText": "BBBBBBBB",
"scalebarUnit": "Kilometers"};
params.map = this.map;
params.template = template;
printTask.on("error",lang.hitch(this, this._printResultError));
printTask.execute(params, lang.hitch(this, this._printResult));
_printResultError:function(err)
{
alert(err);
},
_printResult:function(res){
window.open(res.url, "_blank")
},
Mohan,
Preserve extent is going to the closest you can get to your map view when printing, but as you notice it will not be identical to what is seen in the apps map. The reason is that the print service does not try to print the screen it takes all of the maps Map Services and graphics and back on the server re-builds the map and produces the image to print (that's just the way it is).