Click here to Skip to main content
13,049,722 members (69,308 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I'm trying to convert HTML Text to a .bmp image. I'm using the following code for performing the operation.

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><head></head><body><p>This is a sh*tty html code</p><p>This is another html line</p></body>", point, maxSize);

"HtmlRenderer" is an external namespace that is being used here. However, I'm getting an exception at the "m_Bitmap.Save(@"C:\Test.bmp");" line that says : A generic error occured in GDI+.

I'm unable to understand why this exception is being raised when the same code is running perfectly in my colleague's system.

Please help. Thanks a lot.
Posted 12-May-13 5:01am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Solved. As I was trying to save the image in the root directory (C:\), the program had to have admin privileges. I missed out on that earlier. When I ran the program with admin rights, it worked as expected.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 13 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100