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
|