12

Can anyone point me to some sample code in C# for converting an html table to image? I know how to convert text to image but i need to create an image of well formatted text. The whole text is formatted in html table.

3 Answers3

6

You can use the WebBrowser.DrawToBitmap method. Here is an example. So what I would do is create a page dynamically with the table you want, and nothing but the table, then use the DrawToBitmap method to save it to an image file.

Ron
  • 1,786
  • 19
  • 20
1

Best is to use http://iecapt.sourceforge.net/

Oak Bytes
  • 4,649
  • 4
  • 36
  • 53
Ravi Vanapalli
  • 9,805
  • 3
  • 33
  • 43
0

Converting HTML to bitmap is difficult task. You will need first a rendering engine capable of handling HTML and optionally javascript and css (in case you want to support them). Using a WebBrowser control could be done but there might be better ways.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928