Print Template Sample Javascript Code

4434
3
05-14-2013 08:00 PM
nanasyazana
New Contributor
Print Template Sample Javascript Code
Hi, Im new here in GIS field,
Currently im working on web map application using javascript..
the sample of print template that you given is not working..
the print_button not show up..please look at back your coding and make it accessible for ease me to customize the other template for print..
i need to code print template of A0, A1, A3, and A4.. this is the link of print template esri webtemplate..
http://help.arcgis.com/en/webapi/jav...i_request.html

copy the javascript code and run the code.. the button not appear..
please respond it a.s.a.p...thank you..
0 Kudos
3 Replies
AndyLarkin1
New Contributor
use this sample http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/widget_print_webmap.htmland change this code
 var layouts = [
        { 
            "name": orient_map, //[ A3 Landscape, A3 Portrait, A4 Landscape, A4 Portrait, Letter ANSI A Landscape, ... ] 
            "format": "jpg", 
      "label": "Print", 
            "options": { 
              "legendLayers": "", // empty array means no legend
       
              "authorText": "",
              "scalebarUnit": "",
              "titleText":'<p>'+ printTitle+'</p>'
            }
        }
0 Kudos
nanasyazana
New Contributor
thanks for the feedback Mr. Andy.. i already change the code with the example you gave but its still not working.. here is my code for print layout:

   function createPrintDijit(printTitle) {
        var layoutTemplate, templateNames, mapOnlyIndex, templates;
       
        // create an array of objects that will be used to create print templates
        var layouts = [
          {
            "name": "A4 Landscape",
            "label": "A4 Landscape",
            "format": "pdf",
            "options": {
              "legendLayers": [], // empty array means no legend
              "scalebarUnit": "Miles",
              "titleText": printTitle + ", A4 Landscape PDF"
            }
          },  {
            "name": "A3 Landscape",
            "label": "A3 Landscape",
            "format": "pdf",
            "options": {
              "legendLayers": [], // empty array means no legend
              "scalebarUnit": "Miles",
              "titleText": printTitle + ", A3 Landscape PDF"
            }
          }, {
            "name": "ISO A1 Landscape",
            "label": "A1 Landscape",
            "format": "pdf",
            "options": {
              "legendLayers": [], // empty array means no legend
              "scalebarUnit": "Miles",
              "titleText": printTitle + ", A1 Landscape PDF"
            }
          },{
            "name": "ISO A0 Landscape",
            "label": "A0 Landscape",
            "format": "pdf",
            "options":  {
              "legendLayers": [],
              "scaleBarUnit": "Miles",
              "titleText": printTitle + ", A0 Landscape PDF"
            }
          }
        ];
       
        // create the print templates, could also use dojo.map
        var templates = [];
        dojo.forEach(layouts, function(lo) {
          var t = new esri.tasks.PrintTemplate();
          t.layout = lo.name;
          t.label = lo.label;
          t.format = lo.format;
          t.layoutOptions = lo.options
          templates.push(t);
        });

        app.printer = new esri.dijit.Print({
          "map": app.map,
          "templates": templates,
          url: app.printUrl,
        }, dojo.byId("print_button"));
        app.printer.startup();
      }


// the print service from app.printUrl = "http://localhost:6080/arcgis/rest/services/print/GPServer/Export%20Web%20Map"; only can run for layout A4 and A3 only.. whats wrong with that service? and how can i use my own basemap and layer? i already change the code of webmapId and map but the print service not working..can you please help me??
0 Kudos
AndyLarkin1
New Contributor
you should create templates folder, where you put your templates(A0... .mxd)
Full path to the folder where map documents (.mxd's) to be used as Layout Templates are located. The default location is <install_directory>\Templates\ExportWebMapTemplates.
0 Kudos