如何在html2canvas的html中打印标签图像

时间:2018-08-06 15:26:37

标签: javascript jquery html html2canvas

html2canvas($('#head'), {
    allowTaint: true,
            onrendered: function (canvas) {
        var base64image = canvas.toDataURL("image/png");
        console.log(base64image);

    }
});

example

1 个答案:

答案 0 :(得分:0)

尝试一下!

html2canvas($('#head'), {
    onrendered: function(canvas) {
        var base64image = canvas.toDataURL("image/png");
        var tWindow = window.open("");
        $(tWindow.document.body)
            .html("<img id='Image' src=" + base64image + " style='width:100%;'></img>")
            .ready(function() {
                tWindow.focus();
                tWindow.print();
            });
        }
    });