PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Oct 19, 2024 9:58 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sat Dec 06, 2008 2:56 am 
Offline

Joined: Sat Dec 06, 2008 2:42 am
Posts: 1
Hey guys, I know this topic has been touched on a few times before, namely:

-- pdfsharp-ftopic305.html&highlight=medium+trust

-- pdfsharp-ftopic26.html&highlight=medium+trust

-- pdfsharp-ftopic25.html&highlight=medium+trust

...but I didn't really see any resolutions, plus the posts are a little old. Additionally, the first post says that the next version would work under medium trust and should be out in a "few months." Has that been released yet (doesn't appear so)?

Here's what I have done thus far. I have signed the project, and I have added "[assembly: AllowPartiallyTrustedCallers]" to AssemblyInfo.cs. After doing that, I don't get the normal trust issue error, but I get this:

-- Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

I just migrated all of my customers to a new hosting provider. Moving to a different host isn't really an option. Is there ANY way to get this working under medium trust? To be clear, I cannot edit the Web server's config files in any manner (shared hosting -- not a dedicated server). So this has to be a solution that involves PDFSharp itself -- not changing the server configuration.

Thanks in advance,
JC


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Dec 08, 2008 12:41 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3111
Location: Cologne, Germany
That's not my area of expertise.

PDFsharp supports two modes: GDI+ mode and WPF mode (WPF mode is marked beta).

GDI+ doesn't provide font information to medium trust callers. That's why GDI+ mode cannot be used with Medium Trust.

I've heard from responsible team members that WPF mode should work with Medium Trust, but haven't tried it myself.

We'll convert some of our applications to WPF mode in the months to come.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 04, 2009 8:31 pm 
Offline

Joined: Wed Nov 04, 2009 8:20 pm
Posts: 1
Rendering a PDF for download or email is a very common task for an e-commerce website. One thing to consider when deciding on a PDF library for rendering is what environment the site is running in. Most ASP.Net shared hosting solutions will restrict their hosted sites to Medium trust to prevent a rogue site from peeking at other sites on the server.

Medium trust environments can cause funny things to happen between the development environment and the production environment. By default the websites created in Visual Studio have Full trust, this can cause security problems after deployment if you haven't setup your development environment to mimic production. A good first step is to add a trust level to your web.config system.web section.

<system.web>
<trust level="Medium" />
...
</system.web>

This will help to find any trust issues while developing.

So to rendering PDF. After trying ReportViewer 2008 in local mode and PDFSharp (both of which are still very good at rendering PDFs), I have found success with iTextSharp. ReportViewer and PDFSharp both require Full trust mode because they use native COM dlls as part of the GDI rendering process. This makes them unsuitable for shared hosting environments unless you can convince your hoster to raise your site's trust level. The PDFSharp Wiki says that release 1.30 solves most medium trust issues and that full support is in the near future, which is promising. My car also has most of it's wheels, but until I put the fourth one on it isn't going to go far on the road.

iTextSharp appears to have less documentation on the web (one of the best being a fairly comprehensive iTextSharp tutorial), but it is just as powerful as PDFSharp or ReportViewer. The best thing about it though is that it can run in Medium trust mode - once a minor change is made to allow partially trusted callers. To make this change download the iTextSharp source distribution (http://sourceforge.net/projects/itextsharp/files/)
Modify the AssemblyInfo.cs file to add the partially trusted callers attribute.

[assembly: AllowPartiallyTrustedCallers()]

Rebuild the iTextSharp assembly and it should be good to go in a Medium trust environment.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 33 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group