Friedrich
Friedrich

Reputation: 645

HTML DOM string copy, Canvas element not redrawn

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?

Upvotes: 0

Views: 236

Answers (1)

Alejandro Urbano Alvarez
Alejandro Urbano Alvarez

Reputation: 3346

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.

Upvotes: 1

Related Questions