I am trying to export my HTML Canvas to an Image. But when I export the image, I keep getting the img src = "undefined". I printed the canvas to the page directly and confirmed I am getting the correct canvas. Here's the code that I'm using. Please let me know what you see is wrong. May be a problem with CORS (This is HTML5)?
scope.getShuttleImage = function () {
var tmpPng
var imageElement
html2canvas(document.body.getElementsByClassName("shuttle-truck"), {
useCORS: true,
onrendered: function (canvas) {
tmpPng = canvas.toDataURL("image/png");
}
});
document.write('<img src= "' + tmpPng+'"/>"') // Just for testings sake
};