Here's my code again since it seems it did'nt work the first time :
printUrl = "http://MYSERVER/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task";
var printInfo = esriRequest({
"url": printUrl,
"content": { "f": "json" }
});
printInfo.then(dojo.hitch(printUrl,dojo.hitch(myMap,handlePrintInfo)), handleError);
function handlePrintInfo(resp) {
var layoutTemplate, templateNames, mapOnlyIndex, templates;
layoutTemplate = arrayUtils.filter(resp.parameters, function(param, idx) {
return param.name === "Layout_Template";
});
if ( layoutTemplate.length === 0 ) {
console.log("print service parameters name for templates must be \"Layout_Template\"");
return;
}
templateNames = layoutTemplate[0].choiceList;
// remove the MAP_ONLY template then add it to the end of the list of templates
mapOnlyIndex = arrayUtils.indexOf(templateNames, "MAP_ONLY");
if ( mapOnlyIndex > -1 ) {
var mapOnly = templateNames.splice(mapOnlyIndex, mapOnlyIndex + 1)[0];
templateNames.push(mapOnly);
}
// create a print template for each choice
templates = arrayUtils.map(templateNames, function(ch) {
var plate = new PrintTemplate();
plate.layout = plate.label = ch;
plate.format = "PDF";
plate.layoutOptions = {
"authorText": "Auteur.",
"copyrightText": "<copyright info here>",
"legendLayers": [],
"titleText": "Un titre",
"scalebarUnit": "Kilometers"
};
return plate;
});
// create the print dijit
var printer = new Print({
"map": myMap,
"templates": templates,
"url": printUrl
}, dojo.byId("print_button"));
printer.startup();
}
function handleError(err) {
console.log("Something broke: ", err);
}