Here is the program using swingsprovided by java.
public class MyClass {
public static void main(String[] args) throws IOException {
URL url = MyClass.class.getResource("myhtml.html");
Dimension size = new Dimension(200, 200);
Image img = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
JFrame frame = new JFrame();
frame.setUndecorated(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JEditorPane pane = new JEditorPane(url) {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
}
};
frame.setSize(size);
frame.add(pane);
frame.setVisible(true);
Graphics g = img.getGraphics();
pane.paintAll(g);
ImageIO.write((RenderedImage) img, "jpg", new FileOutputStream("myimg.jpg"));
frame.setVisible(false);
frame.dispose();
}
}
But it will show a flash (uncleared frame for a second).
here is the example i used:
myhtml.html:
<table border="1">
<tr><td>one</td><td>two</td><td>three</td></tr>
<tr><td>four</td><td>five</td><td>six</td></tr>
<tr><td>seven</td><td>eight</td><td>nine</td></tr>
</table>

I admit that this is not an effective method for this. but this is done with the standard gui provided by java