Is it possible to capture or print what’s displayed in an html canvas as an image or pdf?
I’d like to generate an image via canvas, and be able to generate a png from that image.
Is it possible to capture or print what’s displayed in an html canvas as an image or pdf?
I’d like to generate an image via canvas, and be able to generate a png from that image.
Original answer was specific to a similar question. This has been revised:
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.getElementById("existing-image-id").src = img;
or
document.write('<img src="'+img+'"/>');