感谢大家的回应。我使用HtmlRenderer外部dll(库)来实现相同目的,并在下面的代码中找到了相同的东西。
这是代码
public void ConvertHtmlToImage(){ Bitmap m_Bitmap = new Bitmap(400, 600); PointF point = new PointF(0, 0); SizeF maxSize = new System.Drawing.SizeF(500, 500); HtmlRenderer.HtmlRender.Render(Graphics.FromImage(m_Bitmap), "<html><body><p>This is a shitty html pre</p>" + "<p>This is another html line</p></body>",point, maxSize); m_Bitmap.Save(@"C:Test.png", ImageFormat.Png);}


