Click here to Skip to main content
11,721,289 members (83,359 online)
Rate this: bad
good
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);
 
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 12-May-13 5:01am

1 solution

Rate this: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 515
1 OriginalGriff 279
2 Mika Wendelius 170
3 F-ES Sitecore 150
4 cyycoish 70
0 Sergey Alexandrovich Kryukov 2,209
1 OriginalGriff 969
2 F-ES Sitecore 660
3 Maciej Los 609
4 Richard MacCutchan 560


Advertise | Privacy | Mobile
Web04 | 2.8.150901.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