Skip to content
Christoph Burgmer edited this page Aug 30, 2021 · 8 revisions

Simply drawing some HTML

var canvas = document.getElementById("canvas"),
    html = "<span>Some HTML</span>";

rasterizeHTML.drawHTML(html, canvas);

Demo: https://jsfiddle.net/cburgmer/E8fb2/1690/

Putting the HTML on the canvas ourselves

var canvas = document.getElementById("canvas"),
    context = canvas.getContext('2d'),
    html = "<span>Some more HTML</span>";

rasterizeHTML.drawHTML(html).then(function (renderResult) {
    context.drawImage(renderResult.image, 10, 25);
});

Demo: https://jsfiddle.net/cburgmer/dop90uLt/