function Print(){
alert("Found Printing Start");
var printUrl = "http://myserver:6080/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task";
//REST URL: http://myserver:6080/arcgis/rest/services/Utilities/PrintingTools/GPServer
//SOAP URL: http://myserver:6080/arcgis/services/Utilities/PrintingTools/GPServer
//Set up print stuff
var printTask = new esri.tasks.PrintTask(printUrl);
var params = new esri.tasks.PrintParameters();
var template = new esri.tasks.PrintTemplate();
params.map = map;
alert("Found Mark 1");
template.exportOptions = {
width: 595,
height: 842,
dpi: 96
};
template.format = "PDF"
template.layout = "Letter ANSI A Landscape";
template.preserveScale = false;
alert("Found Mark 2");
params.template = template;
alert("Found Mark 3");
//dojo.connect(map, "onLoad", function() {//Fire the print task
printTask.execute(params, printResult, printError);
setTimeout(function(){printTask.execute(params, printResult, printError);},2500);
alert("Found Mark 4");
};
function printResult(result){
console.log(result.url)
}
function printError(result){
console.log(result);
}
esri.config.defaults.io.proxyUrl = 'http://..../proxy.ashx';
printRequest = esri.request({
url: "http://.../rest/services/Geoprocessing/WebMapPDF/GPServer/Export%20Web%20Map",
content: { f: "json" },
callbackParamName: "callback",
handleAs: "json"//,
});
printTypes = new Array();
layoutTypes = new Array();
printRequest.then(
function (response, input) {
// load printType list
//printTypes, layoutTypes
for (var i = 0; i < response.parameters[2].choiceList.length; i++) {
printTypes.push(
{
label: response.parameters[2].choiceList,
value: response.parameters[2].choiceList
});
}
// load printLayout list
for (var i = 0; i < response.parameters[3].choiceList.length - 1; i++) { // use length -1 to omit "MAP_ONLY" option
// Build normal name of print option
layoutName = response.parameters[3].choiceList;
layoutTypes.push({ label: layoutName, value: response.parameters[3].choiceList });
}
select = dojo.byId("printExportType");
if (dojo.byId("printButton") == undefined || dojo.byId("printButton") == null) {
select = new dijit.form.Select(
{
id: "printExportType",
//name: "printExportType",
options: printTypes,
value: printTypes[0].value,
onChange: function () {
printTemplate.format = dijit.byId("printExportType").get("value");
dojo.byId("printButton").textContent = "Generate " + dijit.byId("printExportType").get("value");
}
});
dojo.place(select.domNode, dojo.byId("toolInput"), "last");
// Create combo button to select template
select = new dijit.form.Select(
{
id: "printLayoutTemplate",
name: "printLayoutTemplate",
options: layoutTypes,
value: layoutTypes[1].value,
onChange: function () {
printTemplate.layout = dijit.byId("printLayoutTemplate").get("value");
}
});