Convert Html Code to Image JPG PNG in asp.net C#

Hello Friends,

Here are code for convert html code to Image JPG PNG in asp.net c#

First Install Nuget Package by Following Command.


  • Install-Package HtmlRenderer.WinForms -Version 1.4.13


then Use Following c# code to generate image.



            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 whatsappfb html code</p>"
                                                    + "<p>This is another html line</p></body>",
                                                     point, maxSize);
            m_Bitmap.Save(@"D:\Test.png", ImageFormat.Png);

Comments

Popular posts from this blog