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

I have a GWT application that generates an HTML string. I want to convert this string to an image, for example

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

I tried using Html2Image , which works when I test it locally in normal Java code (with 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 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) 

It’s pretty clear what the problem is, is there an alternative library?

Thanks in advance. PB

+1
source share
2 answers

The conversion API will handle this for you.

+1
source

I'm not sure how you get the image.

If it is a file in the file system, and if you can use a simple gateway for this purpose, it can be easily done with CutyCapt .

Since its binary file, you can save the gateway or request queue and constantly create an image if a request arrives.

However, if you expect a BufferedImage , this might be wrong.

Thanks.

0
source

Source: https://habr.com/ru/post/1392077/


All Articles