I am using http://cburgmer.github.io/rasterizeHTML.js/ to turn html into a canvas. When I change the code to:
var canvas = document.getElementById("save_image_canvas");
// rasterizeHTML.drawHTML('<div style="font-size: 20px;">Some <span style="color: green">HTML</span> with an image</div>', canvas);
rasterizeHTML.drawHTML(document.getElementById("mattes").innerHTML, canvas);
I get the following error in the console:
Blocked script execution in 'Mysite/Custom_App/' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
All the scripts and content are located on the same server.
Here is the full function:
function common_screenshot()
{
var canvas = document.getElementById("save_image_canvas");
if (typeof(moulding_canvas) === "undefined")
{
canvas.height = parseInt($("#matte_canvas").height());
canvas.width = parseInt($("#matte_canvas").width());
}
else
{
canvas.height = parseInt($("#moulding_canvas").height());
canvas.width = parseInt($("#moulding_canvas").width());
}
canvas.style.backgroundColor = "#FFFFFF";
var moulding_top = -1 * parseInt(document.getElementById("moulding_canvas").style.top);
var moulding_left = -1 * parseInt(document.getElementById("moulding_canvas").style.left);
console.log("top: " + moulding_top);
rasterizeHTML.drawHTML(document.getElementById("mattes").innerHTML).then(function (renderResult)
{
context.drawImage(renderResult.image, moulding_left, moulding_top);
});
var ctx = canvas.getContext('2d');
ctx.drawImage(matte_canvas, moulding_left, moulding_top);
if (typeof(moulding_canvas) !== "undefined")
{
ctx.drawImage(moulding_canvas, 0, 0);
}
var image = new Image();
image.src = canvas.toDataURL("image/jpeg");
return image;
}
The image that results from the rasterizeHTML is fine when it is on the screen, but when I call canvas.toDataURL
, the image that results is all black.