PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Security Problem
https://forum.pdfsharp.net/viewtopic.php?f=2&t=927
Page 1 of 1

Author:  DNRN [ Tue Nov 03, 2009 1:44 pm ]
Post subject:  Security Problem

Hi I'm a bit new to both asp.net and pdfSharp.

I'm trying to make some report pdf's and everything is nice and good. But now have I moved from my local server to the developing server, and have meet some issues.

I get a security exception:
Code:
Exception Details: System.Security.SecurityException: System.Security.Permissions.SecurityPermission

XFont pdfTitle = new XFont("Arial", 20, XFontStyle.BoldItalic);

I know I might solve this by changing the permissions.

But I would like to use the fonts from an external folder e.g ~/Resources/Fonts/
So I don't have to make the site more unsecured, due to some fonts.

How do I accomplish this? Any help would really be appreciated :)

And thx for the good library :D

Author:  Thomas Hoevel [ Tue Nov 03, 2009 2:53 pm ]
Post subject:  Re: Security Problem

Hi!

You can use a PrivateFontCollection to avoid this.

Using PDFsharp 1.3, PrivateFontCollection works in the WPF build.

Using PDFsharp 1.2, PrivateFontCollection works in the GDI+ build.

Author:  DNRN [ Tue Nov 03, 2009 2:57 pm ]
Post subject:  Re: Security Problem

Sorry not to make everything more complicated. But I have just used the standard font from asp.net, to what seems, to be without problems:

Code:
Font pdfTitle = new Font("Arial", 20, FontStyle.Bold);
Font heading1 = new Font("Arial", 14, FontStyle.Bold);
Font heading2 = new Font("Arial", 12, FontStyle.Bold);
Font normal = new Font("Arial", 12, FontStyle.Regular);


But now I get another security problem:

Code:
XGraphics gfx = XGraphics.FromPdfPage(page);

And the stack if it helps:
Code:
[SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
   System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
   System.Security.CodeAccessPermission.Demand() +54
   System.Drawing.Graphics.FromHwnd(IntPtr hwnd) +66
   PdfSharp.Drawing.XGraphics..ctor(PdfPage page, XGraphicsPdfPageOptions options, XGraphicsUnit pageUnit, XPageDirection pageDirection) +404
   PdfSharp.Drawing.XGraphics.FromPdfPage(PdfPage page) +53
   ReportGenerator.createPdf() in c:\projekter\truckid\TruckIDWeb\App_Code\ReportGenerator.cs:137
   Reports_UserReports.Button1_Click(Object sender, EventArgs e) in c:\projekter\truckid\TruckIDWeb\Reports\UserReports.aspx.cs:98
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +11041511
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +11041050
   System.Web.UI.Page.ProcessRequest() +91
   System.Web.UI.Page.ProcessRequest(HttpContext context) +240
   ASP.reports_userreports_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\truckidweb\1ee09bba\44640288\App_Web_zkh0ouwy.2.cs:0
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +599
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171


So I really don't understand what there's going on? I would really like to get enlighten on this one :)

Author:  Thomas Hoevel [ Tue Nov 03, 2009 3:10 pm ]
Post subject:  Re: Security Problem

See also here:
http://www.pdfsharp.net/wiki/PDFsharpFA ... um_Trust_5

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/