I am currently using Cobra: Java HTML Renderer and Parser to render an HTML page that is dynamically generated based on user preferences in a java application.
In my application, the user has a choice of hundreds of items to choose from. Items are displayed as special, uniquely colored characters, and the user can select more than one item.
After selecting several elements, their written description is dynamically generated and formatted to include the css2 and html4 tags and loaded into the Cobra HTMLPanel for display.
I want to display a symbol image with a written description of an element in an HTMLPanel.
One way to do this is to save the BufferedImage in a file using ImageIO.write, and then include the html img tag in a dynamically generated HTML document that loads into the HTMLPanel. Unfortunately, this is unacceptable because the user can select hundreds of characters, which in turn will lead to hundreds of ImageIO.write calls and an incredible decrease in the performance of my application.
An alternative way would be to convert the BufferedImage to Base64 encoding, and then directly put the encoding into an HTML document as follows
<img alt="Embedded Image" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA..." />
Unfortunately, the HTMLPanel seems to ignore the data URI scheme.
Does anyone know a solution?
source share