More Thoughts on HTML To Image (Plus Code)

Posted By : todd sharp Posted At : April 5, 2008 8:08 AM Posted In: Java, ColdFusion

4

Yesterday I posted a demo of a UDF that I had been working on to convert HTML (via a URL or raw HTML) to an image. The UDF works OK, but to be honest it's not all that great. Let me quickly explain the process (as some had guessed in the comments on that post yesterday).

Essentially I'm tapping into some Java objects that are used internally in CF 8 for the HTML rendering for <cfpresentation> and creating an internal web browser using that API. I then load the remote URL (or HTML string) into that browser and paint the contents into a buffered image. In theory it works. Unfortunately the HTML rendering engine is not all that hot when it comes to CSS support (as you can see in the following screenshots):

My blog:

ColdFusionBloggers.org:

Dan Vega's Blog:

As I said, not so hot. So I'm releasing the code (under the Apache license) in hopes that it's useful to someone and by some off chance someone has some thoughts on how to improve it (see attachment below). I'm thinking of some other possible solutions, so I haven't completely given up on the idea yet.

PS - don't get me wrong, I do think the component is useful. If you slide it in your application please let me know.

Comments (4)

Justin Carter's Gravatar Looks cool Todd :) Out of curiosity did you try the ICEbrowser trial version to see if the rendering has improved, or are the components that ship with CF8 fairly up-to-date?

Those ICE products seem to cost a bomb!

todd sharp's Gravatar I did try the trial version - it was crap as well. I can't believe people pay for that...

My next thought was to dig in and see if anyone has implemented the open source Webkit html rendering engine in Java. That will have to wait though, because for what I'm doing this UDF is working fine (just simple raw HTML to image).

Levii Smith's Gravatar Has there been any further work on this, or any luck with finding a webkit html rendering engine in Java? I'm looking to do something like this in CFMX7, but so far haven't been having any luck.

Thanks.

Don Q's Gravatar I'm a little late in the game, just wanted to throw what I came up with into the mix, it still has some rendering issues with complex (i guess you could call it 'complex')

http://pastebin.com/f2747b874