Printing: Show Attribution

5946
8
Jump to solution
01-11-2013 05:28 AM
MarkHoover
Occasional Contributor II
This seems like it should be relatively straightforward to get to work, but for me, setting showAttribution of my PrintTemplate to true or false has no impact on the printed product.  Is there a sample out there that uses this?  Any ideas on why it might not be working?
0 Kudos
1 Solution

Accepted Solutions
KellyHutchins
Esri Frequent Contributor
Mark,

I ran a quick test using the Print Task and that worked for me too. I suspect that this is a print service version issue. The print service the samples are using is published using 10.11:

http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities


      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);       });

View solution in original post

8 Replies
KellyHutchins
Esri Frequent Contributor
Hi  Mark,

I ran a quick test and showAttribution worked for me. Here's my test code:


<!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>


0 Kudos
MarkHoover
Occasional Contributor II
Thanks for the quick reply, Kelly.  Any chance it only works when using the Print Dijit?  That's the only difference I see between our applications.  My print task is quite a bit more complicated since it doesn't use the dijit, but here's the relevant code:

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);
0 Kudos
KellyHutchins
Esri Frequent Contributor
Mark,

I ran a quick test using the Print Task and that worked for me too. I suspect that this is a print service version issue. The print service the samples are using is published using 10.11:

http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities


      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);       });
MarkHoover
Occasional Contributor II
That would make sense, as we're at 10.1 for the moment.  Thanks!
0 Kudos
KaushalShah
New Contributor
That would make sense, as we're at 10.1 for the moment.  Thanks!


I am using arcgis server 10.2 and working on arcgis javascript 3.6 API's. This is not working for me still.
I also tried using my arcgis server printing geo-processing tool - "http://ms02291/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export Web Map Task", still this is not working.

Is it important to include proxy path.

Need urgent help.

regards,
Kaushal Shah.
0 Kudos
RobynGingerich
New Contributor II

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?

0 Kudos
DavidMarquardt
New Contributor III

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).

0 Kudos
DavidMarquardt
New Contributor III
I've been working with ArcGIS 10.1, with service pack one.  Is that what is meant by 10.11?   The code provided by Kelly still doesn't work for me: no difference in printout whether I set showAttribution to true or false.  Have people found that this property works in 10.2?

David
0 Kudos