简体   繁体   中英

GWT: take screenshot of widget

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM