Convert HTML string to image

后端 未结 4 806
终归单人心
终归单人心 2020-11-27 13:00

I have a string variable which holds HTML markup. This HTML markup basically represents the email content.

Now I want to create an image from this string content whi

4条回答
  •  误落风尘
    2020-11-27 13:36

    Thanks all for your responses. I used HtmlRenderer external dll (library) to achieve the same and found below code for the same.

    Here is the code for this

    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),
                                               "

    This is a shitty html code

    " + "

    This is another html line

    ", point, maxSize); m_Bitmap.Save(@"C:\Test.png", ImageFormat.Png); }

提交回复
热议问题