这是我的代码。
//argument x contains an HTML Page
public static void ConvertHtmlToImage(string x)
{
Bitmap m_Bitmap = new Bitmap(600, 800)
`enter code here`;
PointF point = new PointF(0, 0);
SizeF maxSize = new System.Drawing.SizeF(500, 500);
HtmlRender.Render(Graphics.FromImage(m_Bitmap), x, point, maxSize);
if (File.Exists(@"D:\HtmlToImage.png"))
{
File.Delete(@"D:\HtmlToImage.png");
}
m_Bitmap.Save(@"D:\HtmlToImage.png", ImageFormat.Png);
m_Bitmap.Dispose();
GC.Collect();
}