I want to add printing to my Javascript web application. The application is developed in GWT.
My method includes copying the current active view (Widget) to an iFrame and print the iFrame. This works perfectly fine, when using plain HTML. When I add a Canvas Element, the Canvas element is copied as expected but not redrawn. Is there something I am missing?
I don't think you can do it that way, however you could send the canvas as an image to be printed, using someting like the following (in jQuery):
var image = $('canvas').toDataURL("image/png");
Using image
as the src for an image will display the contents of the canvas. Instead of adding a canvas element, add an image witht the same dimensions, and replace its src.