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")
},
Solved! Go to Solution.
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).
Mohan, if you are using WAB then why are you not using the print widget?
Because we need to add custom text in the map , that's the reason we are customizing . Even though in default print widget we are facing same kind of issue.
Mohan,
In the esri print widget you have an advanced button that gives you options for preserving scale, extent, etc.
Robert,
The first image is from application and second one is print out put . I am using default print widget . If you look at the both images the map extent will be different , even though if we choose map extent. Will it work like that ?
Application View
Print View (PDF)
Mohan,
So have you tried preserve scale?
Yes .
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).
Ok Robert . Thank you