<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Print widget implementation : TypeError issue with PrintTask.js in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-widget-implementation-typeerror-issue-with/m-p/307548#M28249</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Miriam,&lt;/P&gt;&lt;P&gt;The baseMapLayerWorld was intended to be a tiled map service layer to act as the map's basemap. I'm hesitating to do what you suggest by adding this layer as a dynamic map service--should this make a difference for map loading?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've added the other requirements, but still get a TypeError related to PrintTask.js&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Oct 2016 20:12:11 GMT</pubDate>
    <dc:creator>NhuMai</dc:creator>
    <dc:date>2016-10-18T20:12:11Z</dc:date>
    <item>
      <title>Print widget implementation : TypeError issue with PrintTask.js</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-widget-implementation-typeerror-issue-with/m-p/307546#M28247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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 &lt;A class="link-titled" href="http://js.arcgis.com/3.17/esri/tasks/PrintTask.js" title="http://js.arcgis.com/3.17/esri/tasks/PrintTask.js" rel="nofollow noopener noreferrer" target="_blank"&gt;http://js.arcgis.com/3.17/esri/tasks/PrintTask.js&lt;/A&gt;:25:13.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Map is created in Map.js&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var map;
var baseMapLayerWorld;

require([
 "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("http://services.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer");
 
 map = new Map("map", {
 center: [-150, -17], // lon, lat
 zoom: 8
 });

map.addLayers([baseMapLayerWorld);
});&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The print widget is implemented in Print.js:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var app = {};
 require([
 "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
 ) {
 parser.parse();

app.printUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task";

esriConfig.defaults.io.proxyUrl = "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 param.name === "Layout_Template";
 });

if ( layoutTemplate.length === 0 ) {
 console.log("print service parameters name for templates must be \"Layout_Template\"");
 return;
 }
 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 &amp;gt; -1 ) {
 var mapOnly = templateNames.splice(mapOnlyIndex, mapOnlyIndex + 1)[0];
 templateNames.push(mapOnly);
 }

// create a print template for each choice
 templates = arrayUtils.map(templateNames, 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": "&amp;lt;copyright info here&amp;gt;",
 "legendLayers": [],
 "titleText": "Pool Permits",
 "scalebarUnit": "Miles"
 };
 return plate;
 });

// create the print dijit
 app.printer = new Print({
 "map": app.map,
 "templates": templates,
 url: app.printUrl
 }, dom.byId("print_button"));
 app.printer.startup();
 }

function handleError(err) {
 console.log("Something broke: ", err);
 }
 });&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;They come together in the index.html:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html dir="ltr"&amp;gt;
&amp;lt;head&amp;gt;
 &amp;lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&amp;gt;
 &amp;lt;meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" /&amp;gt;
 &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/3.17/dijit/themes/claro/claro.css"&amp;gt;
 &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/3.17/esri/css/esri.css"&amp;gt;
 &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/3.18/dojox/layout/resources/ExpandoPane.css"&amp;gt;
 &amp;lt;link rel="stylesheet" href="css/widget_styles.css"&amp;gt;

&amp;lt;script src="https://js.arcgis.com/3.17/"&amp;gt;&amp;lt;/script&amp;gt;

&amp;lt;script type="text/javascript"&amp;gt;
 dojo.require("dojox.layout.ExpandoPane");
 &amp;lt;/script&amp;gt;

&amp;lt;script src="js/Map.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="js/Legend.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="js/Search.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="js/Print.js"&amp;gt;&amp;lt;/script&amp;gt;


&amp;lt;/head&amp;gt;

&amp;lt;body class="claro"&amp;gt;

&amp;lt;div id="content"
 data-dojo-type="dijit/layout/BorderContainer"
 data-dojo-props="design:'headline', gutters:true"
 style="width: 100%; height: 100%; margin: 0;"&amp;gt;

&amp;lt;div id="rightPane"
 data-dojo-type="dojox/layout/ExpandoPane"
 data-dojo-props="region:'right',title:'Widgets',startExpanded:false"&amp;gt;

&amp;lt;div data-dojo-type="dijit/layout/AccordionContainer"&amp;gt;
 &amp;lt;div data-dojo-type="dijit/layout/ContentPane" id="legendPane"
 data-dojo-props="title:'Légende', selected:true"&amp;gt;
 &amp;lt;div id="legendDiv"&amp;gt;&amp;lt;/div&amp;gt;
 &amp;lt;/div&amp;gt;
 &amp;lt;div data-dojo-type="dijit/layout/ContentPane"
 data-dojo-props="title:'Pane 2'"&amp;gt;
 &amp;lt;/div&amp;gt;
 &amp;lt;/div&amp;gt;
 &amp;lt;/div&amp;gt;

&amp;lt;div id="map"
 data-dojo-type="dijit/layout/ContentPane"
 data-dojo-props="region:'center'"
 style="overflow: hidden;width: 100%; height: 100%; margin: 0;"&amp;gt;

&amp;lt;div id="feedback" class="shadow"&amp;gt;
 &amp;lt;h3&amp;gt;
 Print Templates Created from Info Returned by the Print Service using
 &amp;lt;a href="https://developers.arcgis.com/javascript/3/jsapi/esri.request-amd.html"&amp;gt;esri.request&amp;lt;/a&amp;gt;
 &amp;lt;/h3&amp;gt;
 &amp;lt;div id="info"&amp;gt;
 &amp;lt;div id="note"&amp;gt;
 Note: This sample uses an ArcGIS Server version 10.1 export web map task.
 &amp;lt;/div&amp;gt;


 &amp;lt;div id="print_button"&amp;gt;&amp;lt;/div&amp;gt;

&amp;lt;div id="info"&amp;gt;
 &amp;lt;a href="https://developers.arcgis.com/javascript/3/jsapi/printtemplate.html"&amp;gt;Print templates&amp;lt;/a&amp;gt; are generated
 from the Export Web Map Task's &amp;lt;a href="https://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"&amp;gt;Layout_Template parameter&amp;lt;/a&amp;gt;. This info is retrieved from the service
 using &amp;lt;a href="https://developers.arcgis.com/javascript/3/jsapi/esri.request-amd.html"&amp;gt;esri.request&amp;lt;/a&amp;gt;.
 &amp;lt;/div&amp;gt;

&amp;lt;/div&amp;gt;
 &amp;lt;/div&amp;gt;
 &amp;lt;/div&amp;gt;
 &amp;lt;div id="search"&amp;gt;&amp;lt;/div&amp;gt;
 &amp;lt;/div&amp;gt;

&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:19:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-widget-implementation-typeerror-issue-with/m-p/307546#M28247</guid>
      <dc:creator>NhuMai</dc:creator>
      <dc:date>2021-12-12T16:19:22Z</dc:date>
    </item>
    <item>
      <title>Re: Print widget implementation : TypeError issue with PrintTask.js</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-widget-implementation-typeerror-issue-with/m-p/307547#M28248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You forgot to declare&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;"dijit/layout/BorderContainer", "dijit/layout/ContentPane"

in your require. Maybe to complete your require is all that you need.

Also you made a mistake when setup your DynamicMapServiceLayer.
&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Instead of&lt;/PRE&gt;&lt;/PRE&gt;baseMapLayerWorld = new esri.layers.ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer");&lt;BR /&gt;&lt;BR /&gt;you should use the require for the ArcGISTiledMapServiceLayer you load above :&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;baseMapLayerWorld = &lt;STRONG&gt;new DynamicMapServiceLayer&lt;/STRONG&gt;("http://services.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer");&lt;/PRE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:19:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-widget-implementation-typeerror-issue-with/m-p/307547#M28248</guid>
      <dc:creator>MiriamBrockmann</dc:creator>
      <dc:date>2021-12-12T16:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: Print widget implementation : TypeError issue with PrintTask.js</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-widget-implementation-typeerror-issue-with/m-p/307548#M28249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Miriam,&lt;/P&gt;&lt;P&gt;The baseMapLayerWorld was intended to be a tiled map service layer to act as the map's basemap. I'm hesitating to do what you suggest by adding this layer as a dynamic map service--should this make a difference for map loading?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've added the other requirements, but still get a TypeError related to PrintTask.js&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Oct 2016 20:12:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-widget-implementation-typeerror-issue-with/m-p/307548#M28249</guid>
      <dc:creator>NhuMai</dc:creator>
      <dc:date>2016-10-18T20:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: Print widget implementation : TypeError issue with PrintTask.js</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-widget-implementation-typeerror-issue-with/m-p/307549#M28250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good Morning Nhu,&lt;/P&gt;&lt;P&gt;If your basemapLayerWorld is Tiled, then you should use certainly ArcGISTiledMapServiceLayer&lt;/P&gt;&lt;P&gt;but you haven't load the Module in your require.&lt;/P&gt;&lt;P&gt;You mix up legacy module definitions like "new esri.layers.ArcGISTiledMapServiceLayer"&lt;/P&gt;&lt;P&gt;with AMD-Style by using require.&lt;/P&gt;&lt;P&gt;This was what i meant.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So your Project loads, you can choose the Layout, but when you want to Print by using the Button, you get an error, right?&lt;/P&gt;&lt;P&gt;Have you check your console, if the Print is sent correctly?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2016 06:25:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-widget-implementation-typeerror-issue-with/m-p/307549#M28250</guid>
      <dc:creator>MiriamBrockmann</dc:creator>
      <dc:date>2016-10-19T06:25:27Z</dc:date>
    </item>
  </channel>
</rss>

