AnsweredAssumed Answered

Trying to create custom "titleText" for Print template

Question asked by skerb on Nov 8, 2013
Latest reply on Nov 8, 2013 by zj_zou
I'm trying a custom print title, so that the user can enter a specific map title. I'm able to create the prompt but I get an error saying that the mapTitle is not able to be defined. Any ideas?

function createPrintDijit() {
var printTemplates = [
  {
   "name": "Landscape",
   "label": "Landscape",
   "format": "pdf",
   "layout": "Landscape",
   "exportOptions": {
    dpi : 300,
   },
   "layoutOptions": {
    "legendLayers": [],
    "titleText": mapTitle,
    "authorText": "GIS Division",
    "copyrightText": "Murray City",
    "scalebarUnit": "Miles"
            }
  },
  {
   "name": "Portrait",
   "label": "Portrait",
   "format": "pdf",
   "layout": "Portrait",
   "exportOptions": {
    dpi : 300,
   },
   "layoutOptions": {
    "legendLayers": [],
    "titleText": mapTitle,
    "authorText": "GIS Division",
    "copyrightText": "Murray City",
    "scalebarUnit": "Miles"
            }
  },
]


  var templates = [];
        dojo.forEach(printTemplates, function(lo) {
          var t = new esri.tasks.PrintTemplate();
          t.printTemplate = lo.name;  
          t.label = lo.label;
          t.format = lo.format;
          t.layout = lo.layout;
          t.exportOptions = {"dpi":"300"};
          t.layoutOptions = {"titleText": mapTitle,}   
          templates.push(t);
        });


var printer = new esri.dijit.Print(
  { 
    map: map,
    templates: templates,
    url: "http://gisfile:6080/arcgis/rest/services/Printing/MurrayPrinting/GPServer/Export%20Web%20Map",
    "content": {
              "f": "json"
            }
  },
    dojo.byId("printButton")
   
  );
 
  dojo.connect(printer, "onPrintStart", function(){
  mapTitle = prompt ("Enter the Map title");
                            this.templates[1].layoutOptions.titleText = mapTitle;
 
      });   
  printer.startup();
 


}

Outcomes