I make an application canvas. I load more image (png, gif) in canvas. When I click print on my browser (opera), the contents of the canvas tag does not print. With other browsers (FF, IE, Chrome), there is no problem. Why?
Asked
Active
Viewed 1,598 times
3
-
This is a lot like http://stackoverflow.com/questions/5217377/print-out-of-a-html5-canvas although personally I don't like the answer there. – James Clark Dec 07 '11 at 02:31
1 Answers
3
this answer from Capture HTML Canvas as gif/jpg/png/pdf? might be useful.
var canvas = document.getElementById("mycanvas");
var img = canvas.toDataURL("image/png");
with the value in IMG you can write it out as a new Image like so:
document.write('<img src="'+img+'"/>');
-
+1. Not sure why Opera doesn't print canvas elements, but converting to an img via this method solves the problem. Plus, the user can save the image to a file, should they want to. :) – Søren Løvborg Jun 15 '12 at 20:30
-