Reputation: 75
My web page has a canvas inside div. i need to print this div with canvas using javascript . enter image description here
Upvotes: 0
Views: 1349
Reputation: 1660
You can html2Canvas it gives you a png of the visible part of your Website. You can try it via browser console.
Upvotes: 0
Reputation: 15637
You need to convert your canvas to a normal image to achieve this.
Get the data URI containing a representation of the image using the canvas.toDataURL
like this,
var canvasObj = document.getElementById("yourCanvasId");
var imgObj = canvasObj.toDataURL("image/png");
Then you can write the image object as,
document.write('<img src="'+imgObj+'"/>');
This will work fine while taking the printouts.
Hope this helps!.
Upvotes: 1