I'm developing a C# forms application, and I need to render HTML during the paint event of a PictureBox control.
Showing just the relevant part, this is the way I would like to do this.
private void CustomPictureBoxPaint(object sender, PaintEventArgs e) {
Graphics g = e.Graphics;
//render html as on g
}
I found a NuGet library which is able to do it this way. HtmlRenderer.Core has a HtmlRenderer class.
private void CustomPictureBoxPaint(object sender, PaintEventArgs e) {
Graphics g = e.Graphics;
Image image = HtmlRender.RenderToImage(htmlText,new Size(150,150) //htmlText has the HTML as string
g.DrawImage(image,point);
}
But there is one big restriction for it: the background can't be transparent. It is something I need, so my question is the following:
Is there a library which is capable of rendering html with transparent background on a PictureBox, or any other way to achieve my goal?
Alternatively rendering markdown instead of html is also a good solution for me, if there is a way to do it.