3

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?

Matteo Riva
  • 24,728
  • 12
  • 72
  • 104
Adrien
  • 37
  • 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 Answers1

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+'"/>');
Community
  • 1
  • 1
tnt-rox
  • 5,400
  • 2
  • 38
  • 52
  • +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
  • Thanks fro +1.. glad I could help someone! – tnt-rox Jun 24 '12 at 12:28