I had the same problem to take a Bootstrap Modal image. The trick that worked for me was that I added a temporary div view with visibility:hidden at the end of the body, for example, for example:
<div id="TempDataDiv" style="visibility:hidden"></div>
Then, before calling html2canvas I added the contents to this TempDataDiv and deleted the contents in the onrendered function, as shown below (twice to avoid cuts at the edges):
$("#TempDataDiv").html($("#chartDiv").html() + $("#chartDiv").html()); var useHeight = $("#chartDiv").prop('scrollHeight'); html2canvas($("#chartDiv"), { height: useHeight, onrendered: function(canvas) { imageData = canvas.toDataURL(); $("#TempDataDiv").html(""); var win = window.open(); win.document.write("<br><img src='" + imageData + "'/>"); win.print(); } });
I hacked a bit, but worked fine for me.
source share