使用C#的Html表(文本)到图像

时间:2022-09-13 09:31:33

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.

有人能指出我在C#中的一些示例代码,用于将html表转换为图像吗?我知道如何将文本转换为图像,但我需要创建格式良好的文本的图像。整个文本格式化为html表格。

3 个解决方案

#1


5  

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.

您可以使用WebBrowser.DrawToBitmap方法。这是一个例子。所以我要做的是用你想要的表动态创建一个页面,除了表格,然后使用DrawToBitmap方法将其保存到图像文件。

#2


1  

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

最好是使用http://iecapt.sourceforge.net/

#3


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.

将HTML转换为位图是一项艰巨的任务。首先需要一个能够处理HTML的渲染引擎,以及可选的javascript和css(如果你想支持它们)。可以使用WebBrowser控件,但可能有更好的方法。

#1


5  

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.

您可以使用WebBrowser.DrawToBitmap方法。这是一个例子。所以我要做的是用你想要的表动态创建一个页面,除了表格,然后使用DrawToBitmap方法将其保存到图像文件。

#2


1  

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

最好是使用http://iecapt.sourceforge.net/

#3


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.

将HTML转换为位图是一项艰巨的任务。首先需要一个能够处理HTML的渲染引擎,以及可选的javascript和css(如果你想支持它们)。可以使用WebBrowser控件,但可能有更好的方法。