Solved! Go to Solution.
function printMap(){ console.log("print"); var params = new esri.tasks.PrintParameters(); params.map = app.map; var template = new esri.tasks.PrintTemplate(); template.exportOptions = { width: 500, height:400, dpi: 96 }; template.format = "jpg"; template.layout = "MAP_ONLY"; template.showAttribution = false; params.template = template; //print task var printTask = new esri.tasks.PrintTask("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export Web Map Task"); printTask.execute(params, function(result){ window.open(result.url); });
<!doctype html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9"> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <title></title> <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/js/dojo/dijit/themes/nihilo/nihilo.css"> <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/js/esri/css/esri.css"> <style> html, body { height: 100%; width: 100%; margin: 0; padding: 0; } #rightPane{ margin: 0; padding: 10px; background-color: #fff; color: #421b14; width: 180px; } </style> <script>var dojoConfig = { parseOnLoad: true };</script> <script src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.3/"></script> <script> dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("esri.map"); dojo.require("esri.dijit.Print"); var app = {}; app.map = null, app.printer = null; function init() { esri.config.defaults.io.proxyUrl = "/arcgisserver/apis/javascript/proxy/proxy.ashx"; app.map = new esri.Map("map", { center: [-122.049, 45.485], zoom: 10, basemap: "topo" }); var templates = [{ label: "Map", format: "jpg", showAttribution:false, layout: "MAP_ONLY", exportOptions: { width: 500, height: 400, dpi: 96 } }]; // print dijit app.printer = new esri.dijit.Print({ map: app.map, templates: templates, url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task" }, dojo.byId("printButton")); app.printer.startup(); } dojo.ready(init); </script> </head> <body class="nihilo"> <div id="mainWindow" data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="design:'headline',gutters:false" style="width: 100%; height: 100%; margin: 0;"> <div id="map" class="shadow" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'"> </div> <div id="rightPane" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'right'"> <div id="printButton"></div> <hr /> </div> </div> </body> </html>
var printParameters = new esri.tasks.PrintParameters(); printParameters.map = map; printParameters.outSpatialReference = map.spatialReference; var template = new esri.tasks.PrintTemplate(); template.layoutOptions = {}; var format = Ext.getCmp('printFormatComboBox').getValue(); if (format == 'PDF') { template.format = 'pdf'; } else if (format == 'PNG (Image)' || format == 'PowerPoint') { template.format = 'png32'; } if (format == 'PDF' || format == 'PNG (Image)') { template.layout = 'Letter'; template.layout = template.layout + Ext.getCmp('printOrientationComboBox').getValue(); if (Ext.getCmp('printTitleTextField').getValue() != '') { template.layout = template.layout + 'Title'; template.layoutOptions.titleText = Ext.getCmp('printTitleTextField').getValue(); } if (Ext.getCmp('printAuthorTextField').getValue() != '') { template.layout = template.layout + 'Author'; template.layoutOptions.authorText = Ext.getCmp('printAuthorTextField').getValue(); } if (Ext.getCmp('printLegendCheckBox').getValue()) { template.layout = template.layout + 'Legend'; } if (Ext.getCmp('printScalebarCheckBox').getValue()) { template.layout = template.layout + 'Scalebar'; template.layoutOptions.scalebarUnit = Ext.getCmp('printUnitsComboBox').getValue(); } } else if (format == 'PowerPoint') { template.layout = 'PowerPoint'; } var preserveOption = Ext.getCmp('printPreserveComboBox').getValue(); if (preserveOption == 'Extent') { template.preserveScale = false; } else if (preserveOption == 'Scale') { template.preserveScale = true; } var citation = Ext.getCmp('printSourceCheckBox').getValue(); if (citation == true) { template.showAttribution = true; } else if (citation == false) { template.showAttribution = false; } var finalLayers = []; var legendLayer; for (var i = 0; i < this.legendLayers.length; i++) { legendLayer = new esri.tasks.LegendLayer(); legendLayer.layerId = '_' + this.legendLayers; finalLayers.push(legendLayer); } template.layoutOptions.legendLayers = finalLayers; Ext.getCmp('CTSApp').legendLayers = finalLayers; printParameters.template = template; var printTask = new esri.tasks.PrintTask(url, { async: true }); Ext.getCmp('printWindow').getEl().mask('Printing - This may take a moment...'); printTask.execute(printParameters, this.handlePrintResponse, this.printFailure);
function printMap(){ console.log("print"); var params = new esri.tasks.PrintParameters(); params.map = app.map; var template = new esri.tasks.PrintTemplate(); template.exportOptions = { width: 500, height:400, dpi: 96 }; template.format = "jpg"; template.layout = "MAP_ONLY"; template.showAttribution = false; params.template = template; //print task var printTask = new esri.tasks.PrintTask("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export Web Map Task"); printTask.execute(params, function(result){ window.open(result.url); });
That would make sense, as we're at 10.1 for the moment. Thanks!
Hello,
I just thought I'd chime in on this topic as I am experiencing the same problem. I was testing my own print service using the esri sample application: ArcGIS API for JavaScript Sandbox .
I changed the showAttribution property to false in both the map options and print template options. I noticed in the map the attribution would turn on and off. However, when printing to a pdf this property had no effect in my template. The attribution remained in legend area of the pdf. When printing use the Map_ONLY image option I was able to turn off the attribution. The ArcGis server version is 10.2.1. Is this a bug or possibly something wrong with the print layouts of the service?
I'm hoping I'm still talking about the same subject (it's been a year). I found a workaround to get rid of the ESRI citation. In the mxd(s) that is (are) being used for a print template layout, I manually inserted the dynamic text : Service Layer Credits. Once I had this, i set it far, far outside of the printed section of the layout. After recreating my print service, the citation went away (outside of printed area).