Html2canvas: Image not rendering in new window on Chrome!!

Created on 16 Feb 2018  ·  3Comments  ·  Source: niklasvh/html2canvas

function convertToCanvasAndPrint() {
html2canvas(document.getElementById("PositionChartMainDiv")).then(function(canvas) {
var img = canvas.toDataURL();
window.open(img);
});
}

I am using 1.0.0-alpha.10 js library, on chrome above function opens a new window as blank. However, on firefox the image is rendered. Why is it so?

Needs More Information

Most helpful comment

@ABHIKSINGHH The solution:

html2canvas(document.body).then((canvas) => {
    window.open().document.write('<img src="' + canvas.toDataURL() + '" />');
});

All 3 comments

There is nothing in this issue that I can help you with. If you wish to get assistance on your issue, follow the instructions for opening an issue and provide an example on jsfiddle of what isn't working.

@niklasvh : I am trying to take a snapshot of a big org chart and open the image in new window. The chart is inside a div(id=PositionChartMainDiv). But when I call the above function on Print button click, the chart opens on firefox in new window but on chrome the new window is empty with no content in its body. Why such difference in behavior? I really can't share the entire content on jsfiddle as the content is very big.

@ABHIKSINGHH The solution:

html2canvas(document.body).then((canvas) => {
    window.open().document.write('<img src="' + canvas.toDataURL() + '" />');
});
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Josh10101010 picture Josh10101010  ·  3Comments

celik75 picture celik75  ·  4Comments

tibewww picture tibewww  ·  4Comments

dking3876 picture dking3876  ·  4Comments

arzyu picture arzyu  ·  3Comments