GWT: Generate image from html String (.png,jpeg)

2019-08-03 03:15发布

I have a GWT app that generates an HTML String. I want to convert this String to an image e.g

<html>
 <head> </head>    
 <body>
  <several HTML elements including <img too>
 </body>
</html>

I tried to using Html2Image which works when I test it locally in a normal Java code (with a main class)

But when I deploy to Google App Engine (GAE) I get:

    java.lang.NoClassDefFoundError: java.awt.geom.Dimension2D is a restricted class.
 Please see the Google App Engine developer's guide for more details.
        at com.google.apphosting.runtime.security.shared.stub.java.awt.geom.Dimension2D.<clinit>(Dimension2D.java)
        at gui.ava.html.image.generator.HtmlImageGenerator.<clinit>(HtmlImageGenerator.java:26)
        at co.za.cre8.web.lottoShop.server.NotificationServiceImpl.geneateImage(NotificationServiceImpl.java:237)
        at co.za.cre8.web.lottoShop.server.NotificationServiceImpl.sendMessage(NotificationServiceImpl.java:181)

Pretty clear what the problem is, is there an alternative library?

Thanks in advance. PB

2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-08-03 03:38

I'm not sure about, how you are receiving the image.

If it is as a file on file system, and if you can use a simple gateway for this purpose, its easy to do it with CutyCapt.

Since its a binary you can keep gateway or a request queue, and constantly produce the image if a request comes.

However, if you are expecting the BufferedImage , this may not be the right thing.

Thanks.

查看更多
Rolldiameter
3楼-- · 2019-08-03 03:40

The conversion API will handle this for you.

查看更多
登录 后发表回答