<?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: Map2PDF PrintMap.js in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map2pdf-printmap-js/m-p/93557#M8512</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Ann,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't have an idea, what it is, that throws you the syntax error. And I'm not familiar with IIS.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you post your code?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 02 Feb 2011 06:41:01 GMT</pubDate>
    <dc:creator>MarcelKleinmann</dc:creator>
    <dc:date>2011-02-02T06:41:01Z</dc:date>
    <item>
      <title>Map2PDF PrintMap.js</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map2pdf-printmap-js/m-p/93554#M8509</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am a fairly new JSAPI programmer and I am trying to utilize the Map2PDF service in an application.&amp;nbsp; However it doesn't seem to be working completely.&amp;nbsp; I don't think I am calling the PrintMap.js function correctly as nothing is being returned for the layers parameter.&amp;nbsp; I keep receiving the error: "Invalid input json 'layers': A JSONObject text must begin with '{' at character 1 of&amp;nbsp;&amp;nbsp; ."&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any advice?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ann&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jan 2011 15:18:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map2pdf-printmap-js/m-p/93554#M8509</guid>
      <dc:creator>AnnParker</dc:creator>
      <dc:date>2011-01-24T15:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: Map2PDF PrintMap.js</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map2pdf-printmap-js/m-p/93555#M8510</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Ann,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems, as if your request parameter "layers" just contains a ".", instead of the layer urls. Perhaps try the whole thing this way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't use the PrintMap.js, but the MapPrinter.js instead.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;First I get the current http path of my own application and make a new instance of MapPrinter once in my init method, providing my esri.map and the path to the pdf directory of the application (line 1-4)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Later to generate a pdf print, I call the generatePdf method of MapPrinter, providing a pdf name (headline of the later pdf document), a ReportGenerator to use and an empty "params" string (line 6)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
path = self.location.href;
pos = path.lastIndexOf('/');
path = path.substring(0,pos);
mapPrinter = new MapPrinter(map, (path+"/pdf"));

mapPrinter.generatePdf("pdfname", "SampleReport", "");
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This works fine for me. Hope this helps,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Marcello&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:34:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map2pdf-printmap-js/m-p/93555#M8510</guid>
      <dc:creator>MarcelKleinmann</dc:creator>
      <dc:date>2021-12-10T23:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: Map2PDF PrintMap.js</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map2pdf-printmap-js/m-p/93556#M8511</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Marcello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you so much for your reply, I really appreciate your help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately it is still not working.&amp;nbsp; I took your advice and called MapPrinter.js instead.&amp;nbsp; I even looked at the sample.js which also used MapPrinter.js and is automatically installed with Map2PDF (and it works!) and tried to find what I'm doing wrong.&amp;nbsp; No luck.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The print button is now doing nothing and I have a browser error that says "Syntax Error; Line: 1; Char: 24"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can't help but think that maybe the WAR file wasn't deployed properly.&amp;nbsp; Do I have to create a virtual directory for it in IIS?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for sticking with me,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ann&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Jan 2011 17:12:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map2pdf-printmap-js/m-p/93556#M8511</guid>
      <dc:creator>AnnParker</dc:creator>
      <dc:date>2011-01-26T17:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Map2PDF PrintMap.js</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map2pdf-printmap-js/m-p/93557#M8512</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Ann,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't have an idea, what it is, that throws you the syntax error. And I'm not familiar with IIS.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you post your code?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Feb 2011 06:41:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map2pdf-printmap-js/m-p/93557#M8512</guid>
      <dc:creator>MarcelKleinmann</dc:creator>
      <dc:date>2011-02-02T06:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: Map2PDF PrintMap.js</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map2pdf-printmap-js/m-p/93558#M8513</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The code is attached.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank again for your help,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ann&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Feb 2011 18:14:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map2pdf-printmap-js/m-p/93558#M8513</guid>
      <dc:creator>AnnParker</dc:creator>
      <dc:date>2011-02-04T18:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: Map2PDF PrintMap.js</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map2pdf-printmap-js/m-p/93559#M8514</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Ann,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the pdf generating function (print) must not be in your init() method, since there it would be called only once on load of the page.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cut line 64 to 66 and paste to line 77 behind your init():&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var print = function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mapPrinter.generatePdf("title", "report", "");
&amp;nbsp; };&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Second thing: you don't call this function anywhere! Change your code in line 139 to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;a href="javascript:&lt;STRONG&gt;print();&lt;/STRONG&gt;" class="print"&amp;gt;Print&amp;lt;/a&amp;gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best luck!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Marcello&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:34:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map2pdf-printmap-js/m-p/93559#M8514</guid>
      <dc:creator>MarcelKleinmann</dc:creator>
      <dc:date>2021-12-10T23:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: Map2PDF PrintMap.js</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map2pdf-printmap-js/m-p/93560#M8515</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Ann,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;did this help you?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Feb 2011 08:41:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map2pdf-printmap-js/m-p/93560#M8515</guid>
      <dc:creator>MarcelKleinmann</dc:creator>
      <dc:date>2011-02-15T08:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: Map2PDF PrintMap.js</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map2pdf-printmap-js/m-p/93561#M8516</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry for not getting back to you sooner.&amp;nbsp; I had to focus on a more pressing issue.&amp;nbsp; Your last post helped quite a bit, especially pointing out that my print function cannot be in my init() method.&amp;nbsp; However I am still receiving an error.&amp;nbsp; IE is giving this error for the MapPrinter.js file:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'this.map.layerIds' is null or not an object&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am hopeful because at least it is calling the function now.&amp;nbsp; Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, I should apologize about the code that I posted because I did not include the code within an external JS file that I was referencing.&amp;nbsp; That's where the print function (&amp;lt;a href="javascript:print();" class="print"&amp;gt;Print&amp;lt;/a&amp;gt;) was being called.&amp;nbsp; I've been troubleshooting so much that my code is a mess.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And once again, thank you thank you for your help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;~Ann&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Feb 2011 18:32:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map2pdf-printmap-js/m-p/93561#M8516</guid>
      <dc:creator>AnnParker</dc:creator>
      <dc:date>2011-02-15T18:32:05Z</dc:date>
    </item>
    <item>
      <title>'this.map.layerIds' is null or not an object</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map2pdf-printmap-js/m-p/93562#M8517</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Ann,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;obviously the MapPrinter.js doesn't find the layers of your map, when you try to generate the pdf.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The map.layerIds property is a basic property of each &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi_start.htm#jsapi/map.htm"&gt;esri map&lt;/A&gt;&lt;SPAN&gt;, described as:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;layerIds&amp;nbsp; String[]&amp;nbsp; Array of current TiledMapServiceLayers and DynamicMapServiceLayers added to the map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The reason may be that your map variable is empty at the moment of pdf generation (print(); function). Do you use the right variable? When you call print(); in the external js, is the variable empty since referneced in a wrong way? Add an alert at this point to see the value of the property, like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alert("External JS: map layers: "+map.layerIds);&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best luck&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Feb 2011 08:32:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map2pdf-printmap-js/m-p/93562#M8517</guid>
      <dc:creator>MarcelKleinmann</dc:creator>
      <dc:date>2011-02-18T08:32:06Z</dc:date>
    </item>
  </channel>
</rss>

