I have a html that already has a canvas inside it and regular html elements around the canvas.
When I use html2canvas in the outer html, the inner canvas becomes blurred but not the outside elements.
I've tried disabling imageSmoothingEnabled
on the canvas context and increasing scale
on the html2canvas options to no avail.
const options = {
scale : 2,
allowTaint : true,
}
const outerDiv = document.getElementById('outerDiv');
html2canvas(outerDiv, options)
.then(canvas => {
const ctx = canvas.getContext('2d');
ctx.mozImageSmoothingEnabled = false;
ctx.webkitImageSmoothingEnabled = false;
ctx.msImageSmoothingEnabled = false;
ctx.imageSmoothingEnabled = false;
window.open(canvas.toDataURL("image/png", 1.0));
})
HTML out of context example :
<div id="outerDiv">
<h1>Crisp text!</h1>
<canvas></canvas>
</div>
Note : In my actual context, this inner canvas is created using canvg library, which converts svg to canvas, but I think it's unrelated since the output from canvg isn't blurry.