Click here to Skip to main content
15,848,905 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
I'm trying to convert HTML Text to a .bmp image. I'm using the following code for performing the operation.

C#
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);

m_Bitmap.Save(@"C:\Test.bmp");


"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

1 solution

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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900