views:

405

answers:

5

Do you know how to convert (save) HTML to an image? Any format is acceptable: jpg, png, ... I tried this code but it does not correctly convert images from HTML (<img> tag).

A solution in Java would be preferred; however, I would appreciation any approach.

A: 

You mean like, a screen shot?

Cheeso
Yes, like a screenshoot.
Why is this downvoted? Was this an impolite question to ask?
Cheeso
A: 

Your description is a little shy on what your trying to do. Could you please give more details?

If you are just trying to take the html and make an image of it what you might want to try is to create a new image and insert the html as text into the image. Once that is done, you can save the image to the type of your choice. I don't know if this is what you are looking for though.

Scott
+1  A: 

One solution would be to use WebDriver

Another solution could be provided by this article : Capture screenshots with Selenium

They are both Java solutions.

Geo
A: 

If a thumbnail is OK, here's something you might look at:

http://aws.amazon.com/ast/

Willie Wheeler
+1  A: 

Well, here is the outline of a solution, at least:
You need a HTML renderer (Gecko, Webkit et al). Then you need to capture it's "output".

The first approaches that spring to mind are

  • Create a batch tool yourself, using an open source rendering engine - then render this to an image. This could be done with Qt and QWebKit, maybe even with Qt Jambi (for java). There is an example for c++ here, in the Qt developer blog.
  • Automating an X11 browser and using capture to capture the contents of the window. Could be a problem with scrolling, IDK.
gnud