<?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 Map with InfoTemplate/Popup in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-map-with-infotemplate-popup/m-p/1158599#M76838</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/242227"&gt;@HenryKo2&lt;/a&gt;&amp;nbsp;- Could you share a code example of your work around? I am trying to do the exact same thing. I have been able print pop-up and the map separately, but I am struggling to merge them together.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Mar 2022 21:30:25 GMT</pubDate>
    <dc:creator>GennadiiPrykhodko</dc:creator>
    <dc:date>2022-03-28T21:30:25Z</dc:date>
    <item>
      <title>Print Map with InfoTemplate/Popup</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-map-with-infotemplate-popup/m-p/741305#M68601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, in ArcGIS API for JavaScript v3, is it possible to print a map that has Popup or InfoTemplate being displayed?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, in here, popups can show when clicked on the map:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/javascript/3/sandbox/sandbox.html?sample=find_popup" title="https://developers.arcgis.com/javascript/3/sandbox/sandbox.html?sample=find_popup"&gt;ArcGIS API for JavaScript Sandbox&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But how can I print the map including the popup?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried the digit-print widget but no luck:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/javascript/3/sandbox/sandbox.html?sample=widget_print" title="https://developers.arcgis.com/javascript/3/sandbox/sandbox.html?sample=widget_print"&gt;ArcGIS API for JavaScript Sandbox&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know that a screen-capture will work, but it won't have the usual things such as legends, titles... etc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Dec 2019 04:21:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-map-with-infotemplate-popup/m-p/741305#M68601</guid>
      <dc:creator>HenryKo2</dc:creator>
      <dc:date>2019-12-05T04:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: Print Map with InfoTemplate/Popup</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-map-with-infotemplate-popup/m-p/741306#M68602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/262959"&gt;Ryan Libed&lt;/A&gt;‌ wrote a great blog post on this subject using the 4x version of the ArcGIS API for JavaScript:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/people/RLibed-esristaff/blog/2018/12/20/screenshots-with-the-arcgis-api-for-javascript-html2canvas"&gt;https://community.esri.com/people/RLibed-esristaff/blog/2018/12/20/screenshots-with-the-arcgis-api-for-javascript-html2canvas&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Dec 2019 18:40:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-map-with-infotemplate-popup/m-p/741306#M68602</guid>
      <dc:creator>Noah-Sager</dc:creator>
      <dc:date>2019-12-05T18:40:46Z</dc:date>
    </item>
    <item>
      <title>Re: Print Map with InfoTemplate/Popup</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-map-with-infotemplate-popup/m-p/1024775#M71702</link>
      <description>&lt;P&gt;&lt;SPAN&gt;In the end, I got it working as follows:&lt;/SPAN&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN&gt;All the "popup" / "InfoWindow" was implemented as good old plain HTML DIV elements.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;I print these DIV elements using the html2canvas JavaScript library. They are printed as HTML canvas.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;I print the map using the standard ArcGIS for Server print API. The map is printed as HTML canvas. &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Finally, I "merge" the two printed HTML canvases as one PNG image.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;SPAN&gt;(I could print everything using the html2canvas library but there were some weird issues).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hope it helps.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 05:51:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-map-with-infotemplate-popup/m-p/1024775#M71702</guid>
      <dc:creator>HenryKo2</dc:creator>
      <dc:date>2021-02-09T05:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: Print Map with InfoTemplate/Popup</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-map-with-infotemplate-popup/m-p/1158599#M76838</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/242227"&gt;@HenryKo2&lt;/a&gt;&amp;nbsp;- Could you share a code example of your work around? I am trying to do the exact same thing. I have been able print pop-up and the map separately, but I am struggling to merge them together.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 21:30:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-map-with-infotemplate-popup/m-p/1158599#M76838</guid>
      <dc:creator>GennadiiPrykhodko</dc:creator>
      <dc:date>2022-03-28T21:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: Print Map with InfoTemplate/Popup</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-map-with-infotemplate-popup/m-p/1158615#M76840</link>
      <description>&lt;P&gt;With the other canvas/node, I firstly set the background-color to rgba(254, 254, 254, 1.0) in CSS as a hack to flag that the pixels are meant to be transparent (so the map below it can show through).&lt;/P&gt;&lt;P&gt;When I merge the map and other canvas together, I manually loop through the pixels to find (254, 254, 254, 1.0) pixels and then set these to real transparent pixels (i.e. a value is zero).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;mergeCanvases: function(mapCanvas, otherCanvas, mapNode, otherNode) {
    console.log("Merging my canvas on top of map canvas.");

    var srcRect = otherNode.getBoundingClientRect();
    var destRect = mapNode.getBoundingClientRect();

    this.maskContainerBackgroundPixels(otherCanvas, srcRect);

    var mapCanvasContext = mapCanvas.getContext("2d", {
        alpha: true
    });

    // Workaround for different screen resolutions.
    mapCanvasContext.drawImage(otherCanvas, 0, 0, srcRect.width * window.devicePixelRatio, srcRect.height * window.devicePixelRatio, 0, 0, destRect.width, destRect.height);
},

// Use flag of RGB of (254, 254, 254) to pretend it is "transparent" (so the map below it can show through). Using CSS transparency didn't work.
maskContainerBackgroundPixels: function(otherCanvas, rect) {
    console.log("Masking pixels.");

    var otherContext = otherCanvas.getContext("2d");

    // Manually set the container background background pixels to transparent.
    var canvasImageData = otherContext.getImageData(0, 0, rect.width * window.devicePixelRatio, rect.height * window.devicePixelRatio);
    for (var i = 0; i &amp;lt; canvasImageData.data.length; i += 4) {
        var r = canvasImageData.data[i];
        var g = canvasImageData.data[i + 1];
        var b = canvasImageData.data[i + 2];
        var a = canvasImageData.data[i + 3];

        // We know that rgb(254, 254, 254) need to be set to transparent.
        if (r == 254 &amp;amp;&amp;amp; g == 254 &amp;amp;&amp;amp; b == 254 &amp;amp;&amp;amp; a == 255) {
            canvasImageData.data[i] = r;
            canvasImageData.data[i + 1] = g;
            canvasImageData.data[i + 2] = b;
            canvasImageData.data[i + 3] = 0;
        }
    }

    // The container background is now transparent so the map beneath can show through.
    otherContext.putImageData(canvasImageData, 0, 0);
},

/* In CSS set the other container background to rgba(254, 254, 254, 1.0) which flags it as 'transparent' pixel. */
.otherContainer {
	/* This is IMPORTANT for printing - these pixels will be masked to transparent when printing. */
	background-color: rgba(254, 254, 254, 1.0);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 22:07:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-map-with-infotemplate-popup/m-p/1158615#M76840</guid>
      <dc:creator>HenryKo2</dc:creator>
      <dc:date>2022-03-28T22:07:31Z</dc:date>
    </item>
  </channel>
</rss>

