I have an Esri map, and a print task service, After loading the map, I have added custom graphics on my map, but when I tried to take the screenshot by using JavaScript Print Task (esri.tasks.PrintTask), it is only printing the default map same as it is ArcGIS Server, not printing the programmatically added custom graphics. Here is my code.
this.exportWebMap=function(url,map,width,height){
var deferred = new Deferred();
var printTask = new PrintTask(url);
var attrs={};
var template = new PrintTemplate();
var mapWidth=map&&map.width?map.width:this.currentMap.width;
var mapHeight=map&&map.height?map.height:this.currentMap.height;
template.exportOptions = {
width: mapWidth,
height: mapHeight,
dpi: 96
};
template.format = "JPG";
template.layout = "MAP_ONLY",
template.preserveScale = false;
template.showLabels = true;
template.showAttribution = false;
template.layoutOptions = {
"legendLayers": [], // empty array means no legend
"scalebarUnit": "Miles",
"copyrightText": "<div>xxx</div>",
}
var params = new PrintParameters();
params.map = map||this.currentMap;
params.template = template;
printTask.execute(params, function(success){
deferred.resolve(success);
},
function(error){
deferred.resolve(error);
});
return deferred.promise;
}
Print Task JSON
{
"geometryType": "esriGeometryPolygon",
"features": [{
"geometry": {
"rings": [
[
[1394673.6791358888, 433055.85258604586],
[1394680.201104477, 433069.9998674691],
[1394686.46519956, 433083.3777934611],
[1394691.6935355663, 433094.899095878],
[1394704.8713307232, 433089.2193172127],
[1394716.3017540574, 433084.7445886284],
[1394727.1435958892, 433080.7009615451],
[1394739.709843725, 433076.03791312873],
[1394732.3896483928, 433060.93656538427],
[1394724.798128143, 433045.49433904886],
[1394720.2138197273, 433035.48615697026],
[1394708.6295253038, 433040.35196088254],
[1394698.9999513924, 433044.4631731361],
[1394688.3766130656, 433049.2423630506],
[1394677.6417263895, 433053.9851357192],
[1394673.6791358888, 433055.85258604586]
]
],
"spatialReference": {
"wkid": 102723,
"latestWkid": 3735
}
},
"symbol": {
"color": [255, 26, 26, 255],
"width": 1,
"type": "esriSLS",
"style": "esriSLSSolid"
}
}]
}