Select to view content in your preferred language

MapExtent in application not showing properly in Custom Print tool (WAB)

1571
8
Jump to solution
12-08-2017 04:21 AM
mohannainar1
Emerging Contributor

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")
},

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

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).

View solution in original post

8 Replies
RobertScheitlin__GISP
MVP Emeritus

Mohan, if you are using WAB then why are you not using the print widget?

0 Kudos
mohannainar1
Emerging Contributor

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.  

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Mohan,

   In the esri print widget you have an advanced button that gives you options for preserving scale, extent, etc.

0 Kudos
mohannainar1
Emerging Contributor

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)

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Mohan,

   So have you tried preserve scale?

0 Kudos
mohannainar1
Emerging Contributor

Yes .

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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).

mohannainar1
Emerging Contributor

Ok Robert . Thank you

0 Kudos