AnsweredAssumed Answered

Print widget implementation : TypeError issue with PrintTask.js

Question asked by ingenue3911 on Oct 15, 2016
Latest reply on Oct 18, 2016 by TikiLeBrock

This print widget is blocked before creating an output. The combobox properly retrieves the print task url, but the console shows "TypeError: b is undefined" for


Map is created in Map.js


var map;
var baseMapLayerWorld;

"esri/map", "esri/dijit/Search", "esri/layers/ArcGISDynamicMapServiceLayer","esri/layers/FeatureLayer", "esri/InfoTemplate", "dojo/domReady!"
], function (Map, Search, DynamicMapServiceLayer, FeatureLayer, InfoTemplate) {

baseMapLayerWorld = new esri.layers.ArcGISTiledMapServiceLayer("");

map = new Map("map", {
center: [-150, -17], // lon, lat
zoom: 8



The print widget is implemented in Print.js:


var app = {};
"esri/map", "esri/layers/FeatureLayer",
"esri/dijit/Print", "esri/tasks/PrintTemplate",
"esri/request", "esri/config",
"dojo/_base/array", "dojo/dom", "dojo/parser",

"dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dojo/domReady!"
], function(
Map, FeatureLayer,
Print, PrintTemplate,
esriRequest, esriConfig,
arrayUtils, dom, parser
) {

app.printUrl = ""; = "http://our-server/Java/proxy.jsp";

// get print templates from the export web map task
var printInfo = esriRequest({
"url": app.printUrl,
"content": { "f": "json" }
printInfo.then(handlePrintInfo, handleError);

function handlePrintInfo(resp) {
var layoutTemplate, templateNames, mapOnlyIndex, templates;

layoutTemplate = arrayUtils.filter(resp.parameters, function(param, idx) {
return === "Layout_Template";

if ( layoutTemplate.length === 0 ) {
console.log("print service parameters name for templates must be \"Layout_Template\"");
templateNames = layoutTemplate[0].choiceList;

// remove the MAP_ONLY template then add it to the end of the list of templates
mapOnlyIndex = arrayUtils.indexOf(templateNames, "MAP_ONLY");
if ( mapOnlyIndex > -1 ) {
var mapOnly = templateNames.splice(mapOnlyIndex, mapOnlyIndex + 1)[0];

// create a print template for each choice
templates =, function(ch) {
var plate = new PrintTemplate();
plate.layout = plate.label = ch;
plate.format = "PDF";
plate.layoutOptions = {
"authorText": "Made by: Esri's JS API Team",
"copyrightText": "<copyright info here>",
"legendLayers": [],
"titleText": "Pool Permits",
"scalebarUnit": "Miles"
return plate;

// create the print dijit
app.printer = new Print({
"templates": templates,
url: app.printUrl
}, dom.byId("print_button"));

function handleError(err) {
console.log("Something broke: ", err);



They come together in the index.html:


<!DOCTYPE html>
<html dir="ltr">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" />
<link rel="stylesheet" href="">
<link rel="stylesheet" href="">
<link rel="stylesheet" href="">
<link rel="stylesheet" href="css/widget_styles.css">

<script src=""></script>

<script type="text/javascript">

<script src="js/Map.js"></script>
<script src="js/Legend.js"></script>
<script src="js/Search.js"></script>
<script src="js/Print.js"></script>


<body class="claro">

<div id="content"
data-dojo-props="design:'headline', gutters:true"
style="width: 100%; height: 100%; margin: 0;">

<div id="rightPane"

<div data-dojo-type="dijit/layout/AccordionContainer">
<div data-dojo-type="dijit/layout/ContentPane" id="legendPane"
data-dojo-props="title:'Légende', selected:true">
<div id="legendDiv"></div>
<div data-dojo-type="dijit/layout/ContentPane"
data-dojo-props="title:'Pane 2'">

<div id="map"
style="overflow: hidden;width: 100%; height: 100%; margin: 0;">

<div id="feedback" class="shadow">
Print Templates Created from Info Returned by the Print Service using
<a href="">esri.request</a>
<div id="info">
<div id="note">
Note: This sample uses an ArcGIS Server version 10.1 export web map task.

<div id="print_button"></div>

<div id="info">
<a href="">Print templates</a> are generated
from the Export Web Map Task's <a href="">Layout_Template parameter</a>. This info is retrieved from the service
using <a href="">esri.request</a>.

<div id="search"></div>