Here is the code. /**************************** Start Print Functions *****************************/
registry.byId("nav_print").on("click", function ()
{
$("#printform").show();
}
);
function createPrintDijit(printTitle, pageSize, pageOr) {
var printURL = "http://192.168.20.14:6080/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task";
// create an array of objects that will be used to create print templates
var layouts = [
{
"name": pageSize +" "+ pageOr,
"label": "Landscape (PDF)",
"format": "pdf",
"options": {
"legendLayers": [], // empty array means no legend
//"scalebarUnit": "Feet",
"titleText": printTitle
}
}
];
// create the print templates, could also use dojo.map
var templates = [];
dojo.forEach(layouts, function(lo) {
var t = new PrintTemplate();
t.layout = lo.name;
t.label = lo.label;
t.format = lo.format;
t.layoutOptions = lo.options
templates.push(t);
});
printer = new Print({
"map": map,
"templates": templates,
url: printURL,
}, dojo.byId("printMap"));
printer.startup();
}
// Create default print widget
createPrintDijit("PWSB Emap", "Tabloid", "Landscape");
// Re-Create the print button when any of the form fields change
registry.byId("pagetitle").on("change", function ()
{
pageSize = registry.byId("pagesize").get("value");
pageOrient = registry.byId("pageor").get("value");
pageTitle = registry.byId("pagetitle").get("value");
printer.destroy();
console.log(pageTitle+" "+pageSize+" "+pageOrient);
createPrintDijit(pageTitle, pageSize, pageOrient);
}
);
registry.byId("pagesize").on("change", function ()
{
pageSize = registry.byId("pagesize").get("value");
pageOrient = registry.byId("pageor").get("value");
pageTitle = registry.byId("pagetitle").get("value");
printer.destroy();
console.log(pageTitle+" "+pageSize+" "+pageOrient);
createPrintDijit(pageTitle, pageSize, pageOrient);
}
);
registry.byId("pageor").on("change", function ()
{
pageSize = registry.byId("pagesize").get("value");
pageOrient = registry.byId("pageor").get("value");
pageTitle = registry.byId("pagetitle").get("value");
printer.destroy();
//createPrintDijit(pageTitle, pageSize, pageOrient);
}
);
/***************************** End Print Functions ******************************/
I have also made several print templates on the server and named them to what I need.located <arcgisserverdirectory>/Templates/ExportWebMapTemplatesARCH_C LandscapeARCH_C PortraitARCH_D LandscapeARCH_D PortraitLetter LandscapeLetter PortraitTabloid LandscapeTabloid PortraitRay