<STYLE><em> issue

Apr 10, 2014 at 3:07 PM

I'm testing your brilliant control on huge DB with more 110 000 records.

I've found bug. If HTML data contains structure like:
Then it will bomb with NullReferenceException.

To fix that you should add null check to CascadeStyles method of HtmlRenderer.Parse.DomParser class.

Replace string
if (box.HtmlTag.Name.Equals("style", StringComparison.CurrentCultureIgnoreCase) && box.Boxes.Count == 1)
if (box.HtmlTag.Name.Equals("style", StringComparison.CurrentCultureIgnoreCase) && box.Boxes.Count == 1 && box.Boxes[0].Text != null)
Apr 11, 2014 at 2:57 PM
Thx, will be fixed.
I'm planning to do a minor release in a few days so if you found more issues (110000 is a lot of samples) please share so I can fix them in this release.
Apr 11, 2014 at 4:14 PM
Can I contact you directly via email?
I'll send you code which causes StackOverflowException.
Apr 16, 2014 at 2:25 PM
Edited Apr 16, 2014 at 2:25 PM
i have created a sample
public void ConvertHtmlToImage()
        Bitmap m_Bitmap = new Bitmap(400, 600);
        PointF point = new PointF(0, 0);
        SizeF maxSize = new System.Drawing.SizeF(500, 500);
        CssData css = HtmlRenderer.CssData.Parse("font-family:italic,background-color:Yellow;san-serif;font-size:100px;",true);

        var img = HtmlRender.RenderToImage(File.ReadAllText(@"D:\html.txt"), 600);

        HtmlRenderer.HtmlRender.Render(Graphics.FromImage(m_Bitmap),"<html><body><div><div>Hello World, Converting Html To Image!!!</div></div></body></html>",
                                                 point, maxSize,css);

        m_Bitmap.Save(@"D:\Test.png", ImageFormat.Png);


css is not applying for this one and can you help me how can i use external stylesheet i am very new to this one
Apr 16, 2014 at 6:28 PM
I'm going to assume you are interested in something like this:
CssData css = HtmlRenderer.CssData.Parse("body{font-family:italic;background-color:Yellow;san-serif;font-size:100px;}", true);

Image m_Bitmap = HtmlRender.RenderToImage("<html><body><div><div>Hello World, Converting Html To Image!!!</div></div></body></html>", Size.Empty, new System.Drawing.Size(500, 500), Color.White, css);

m_Bitmap.Save(@"D:\Test.png", ImageFormat.Png);
Please invest the time in your code:
  1. You used totally unrelated discussion to ask your question
  2. Your CSS is invalid, really not related to HTML Renderer project.
  3. In related previous discussion I pointed to relevant page: Generate image from HTML markup. If its unclear please let me know how to improve it.
  4. the sample code you provided contains unused code:
var img = HtmlRender.RenderToImage(File.ReadAllText(@"D:\html.txt"), 600);
Good luck,