html2canvas - IndexSizeError
<p>I am trying to take an image that is loaded into a div on my page and try and either pass in the raw data fro the image, or try and copy the image to a location.</p>

<p>The best method i could find was using html2canvas</p>

<p>I am getting the following error when trying to open my image into a window to preview:</p>

<p>JavaScript runtime error: IndexSizeError</p>

<p>I have read a few posts advising that i could render the div using the following method:</p>

<pre><code>html2canvas($("#mapDiv"), {
            onrendered: function (canvas) {
                // canvas is the final rendered &lt;canvas&gt; element
                var imgData = canvas.GetContext("2d").getImageData(bounds.left, bounds.top, bounds.width, bounds.height);
                var myImage = imgData.toDataURL("image/png");
                window.open(myImage);
            }
        });
</code></pre>

<p>The problem is occuring on the following line in the html2canvas js file</p>

<pre><code>ctx.drawImage(canvas, bounds.left, bounds.top, bounds.width, bounds.height, 0, 0, bounds.width, bounds.height);
</code></pre>

<p>Is it possible to render an image that is dynamically loaded into a div in this way, as i cant pass in the pixel parameters due to users having different resolutions</p>

<p>and if it is possible, what am i doing wrong?</p>