Click here to Skip to main content
11,805,604 members (56,538 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# GDI+
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***y 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
0 OriginalGriff 310
1 Richard Deeming 225
2 Sergey Alexandrovich Kryukov 170
3 Abhinav S 128
4 ppolymorphe 125
0 OriginalGriff 3,300
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web03 | 2.8.151002.1 | Last Updated 13 May 2013
Copyright © CodeProject, 1999-2015
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