Manak Kapoor Manak Kapoor - 1 year ago 334
Javascript Question

HTML String in Html2Canvas

How do we pass a valid HTML String into html2canvas?


var html = "<html><head></head><body><p>HI</p></body></html>

The way it is done on

Html2canvas is really great and all but it's very poorly documented.

Answer Source

You can do as following

var iframe=document.createElement('iframe');
    var iframedoc=iframe.contentDocument||iframe.contentWindow.document;
    html2canvas(iframedoc.body, {
        onrendered: function(canvas) {
}, 10);

See the whole code here :


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download