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

    }
});

example

Ashot Karakhanyan
  • 2,804
  • 3
  • 23
  • 28
Rufio Rocco
  • 121
  • 1
  • 6
  • 1
    This question could do with additional context. You mentioned that you don't see an image tag in your DOM, correct? Do you see any errors in your JS console? Any failed network requests? – Richie Thomas Aug 06 '18 at 16:06

1 Answers1

0

Try this!

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();
            });
        }
    });
Nisarg
  • 1,631
  • 6
  • 19
  • 31