0

For a training project I have to use the Google Web Toolkit to create a small app. The app visualizes a dataset either in a table or a map, both can be loaded into a VerticalPanel (which I called mainPanel) and are themselves VerticalPanels.

Now the user should be able to get the visualization as an image and save it to his HDD. In order to achieve this, I want to screenshot the content of the mainPanel.

Is this possible? I've read about HTML5 canvas but this seems to only work in Firefox and only locally. There must be a way to save the content of a widget as an image, otherwise it wouldn't have gotten the task, but I just can't figure out how.

Thank you so much

Ben
  • 109
  • 1
  • 11
  • 1
    Internet Explorer 9+, Firefox, Opera, Chrome, and Safari support the element, I doubt it will help you though. You might want to check this out - http://stackoverflow.com/questions/4912092/using-html5-canvas-javascript-to-take-screenshots – Vineet Kosaraju Dec 01 '13 at 02:06

1 Answers1

0

I think your best bet is to get the HTML from the VerticalPanel (using getElement().getInnerHtml() or something like that).

And then at the server use some library to generate an Image.

A quick google I found https://code.google.com/p/java-html2image/wiki/HtmlImageGenerator

And finally send this back to the client.

Not really an easy task for people learning GWT however.

I don't think a client side only solution, working on all browsers, is possible.

Knarf
  • 2,077
  • 1
  • 16
  • 24