Reputation: 21
I tried this logic but it didn't work:
var canvas = document.getElementById("canvas");
document.body.appendChild(rasterizeHTML.drawHTML(document.body.innerHTML, canvas, {height:'1000px'}));
Options is an object and I tried to pass in it the width and height, but it is not working. The script that I'm using for this library is from cloud flare:
<script src="https://cdnjs.cloudflare.com/ajax/libs/rasterizehtml/1.2.2/rasterizeHTML.allinone.js"></script>
I did it some how but I don't understand why the canvas is not displaying correctly.
const context = canvas.getContext('2d');
canvas.style.width = "100%";
canvas.style.height = "600px";
html = document.querySelector('#main').innerHTML;
document.body.appendChild(
rasterizeHTML.drawHTML(html).then(function (renderResult) {
context.scale(window.devicePixelRatio, window.devicePixelRatio);
context.drawImage(renderResult.image, 0, 0, 1600, 800);
})
);
I tried to put the content of the entire web page in canvas(below under the box with the green border) but it looks like this:
Upvotes: 1
Views: 408