PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
regarding Replacing Graphics.FromHwnd() with new Bitmap() https://forum.pdfsharp.net/viewtopic.php?f=2&t=1746 |
Page 1 of 1 |
Author: | frank [ Thu Aug 18, 2011 8:49 pm ] |
Post subject: | regarding Replacing Graphics.FromHwnd() with new Bitmap() |
In order to use PDFSharp GDI, 1.3 in a medium trust environment I made a change to XGraphics.cs (replacing Graphics.FromHwnd() with a call to new Bitmap()) All seems well, my Security exception is gone, but it appears that you tried the same thing and commented it out. What problem, if any, is there with using new Bitmap() rather than fromHwnd()? thank you -------------- sample code change below from XGraphics.cs: @@ -249,14 +249,14 @@ } page.RenderContent = content; #if GDI // HACK: This does not work with MediumTrust - this.gfx = Graphics.FromHwnd(IntPtr.Zero); - this.targetContext = XGraphicTargetContext.GDI; //Bitmap bm = new Bitmap(10, 10); //this.gfx = Graphics.FromImage(bm); + Bitmap bm = new Bitmap((int)page.Width.Point, (int)page.Height.Point); + this.gfx = Graphics.FromImage(bm); #endif |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |