PrintTemplate showAttribution undefined

853
3
06-13-2013 12:38 PM
PaulHedlund
New Contributor II
I get the following error in Chrome when trying to implement the PrintTemplate.

Uncaught TypeError: Cannot read property 'showAttribution' of undefined

I have showAttribution set to true for both my map and the print template.  Any ideas?


// create the print template
      var template = new esri.tasks.PrintTemplate();
      template.layout = dijit.byId("mapLayout").value;
      template.label = "Test";
      template.format = dijit.byId("imageType").value;
   if (dijit.byId("printLegend").checked){
    template.layoutOptions = { 
       "titleText": dijit.byId("mapTitle").value,
       "authorText": dijit.byId("printAuthor").value,
       "copyrightText": dijit.byId("printCopyright").value,
       "scaleBarUnit": dijit.byId("printScale").value
     }
   }
   else {
    template.layoutOptions = { 
       "titleText": dijit.byId("mapTitle").value,
       "authorText": dijit.byId("printAuthor").value,
       "copyrightText": dijit.byId("printCopyright").value,
       "scaleBarUnit": dijit.byId("printScale").value
     }
   }
   template.preserveScale = true;
   template.showAttribution = true;
   
   //var printTaskURL = ndhx.config.printURL;
   var printTaskURL = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task";
   

   // var printer = new esri.dijit.Print({
     // "map": ndhx.map,
     // url: printTaskURL
   // }, dojo.byId("print_button"));
   
   ndhx.printer = new esri.dijit.Print({
       "map": ndhx.map,
       "templates": template,
       url: printTaskURL
   }, dojo.byId("print_button"));
      
   ndhx.printer.startup();
   
   dojo.connect(ndhx.printer,'onPrintStart',function(){
     console.log('The print operation has started');
   });
   
   dojo.connect(printer,'onError',function(error){
     console.log('The print operation has started');
   });
   
   dojo.connect(printer,'onPrintComplete',function(value){
     console.log('The url to the print image is : ' + value.url);
   }); 
0 Kudos
3 Replies
ShaunWeston
Occasional Contributor
What line is that error referring to? Does it work fine if you remove out the showAttribution?
0 Kudos
PaulHedlund
New Contributor II
I solved my issue, I needed to specify the template as an array.
0 Kudos
RahulGupta1
New Contributor
0 Kudos