This is a migrated thread and some comments may be shown as answers.

Export to PDF in medium Trust

3 Answers 210 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dave Koppe
Top achievements
Rank 1
Dave Koppe asked on 02 Dec 2009, 06:46 AM
The export report to pdf stopped working after upgrading to Q3 2009 Reporting. I found a fix you posted about adding the following web.config to the folder the report viewers are being used.

<?xml version="1.0"?><configuration>
  <system.web>
    <httpHandlers>
      <add path="Telerik.ReportViewer.axd" verb="*" type="Telerik.ReportViewer.WebForms.HttpHandler, Telerik.ReportViewer.WebForms, Version=3.1.9.807, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" validate="true"/>
    </httpHandlers>
  </system.web>
</configuration>

It was working fine until I upgraded to latest release, any idea how to get pdf exports working again? Here my error when exporting.

Server Error in '/' Application.

Security Exception

Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

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

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
   Telerik.Reporting.Pdf.Rendering.PdfRenderer.DrawString(String text, PdfFont font, Brush brush, RectangleF rect, Boolean rightToLeft) +0
   Telerik.Reporting.Pdf.Drawing.PdfGraphics.DrawString(String s, Font font, Brush brush, RectangleF rect, StringFormat format) +124
   Telerik.Reporting.ImageRendering.CanvasPdf.DrawString(String s, Font font, Brush brush, RectangleF rect, StringFormat format) +107
   Telerik.Reporting.Processing.TextRenderer.DrawText(IGraphics g, String text, Font font, Brush brush, RectangleF bounds, Double angle, StringFormat stringFormat) +793
   Telerik.Reporting.ImageRendering.CompositionBase.DrawTrialMessage() +250
   Telerik.Reporting.ImageRendering.CompositionBase.SendPhysicalPages(Boolean force) +59
   Telerik.Reporting.ImageRendering.CompositionBase.End() +75
   Telerik.Reporting.ImageRendering.CompositionPdf.End() +39
   Telerik.Reporting.ImageRendering.CompositionBase.Dispose(Boolean disposing) +22
   Telerik.Reporting.ImageRendering.CompositionPdf.Dispose(Boolean disposing) +11
   Telerik.Reporting.ImageRendering.CompositionBase.System.IDisposable.Dispose() +17
   Telerik.Reporting.ImageRendering.ImageRendererBase.RenderReport(Report report, Hashtable renderingContext, Hashtable deviceInfo, CreateStream createStreamCallback, EvaluateHeaderFooterExpressions evalHeaderFooterCallback) +242
   Telerik.Reporting.ImageRendering.ImageRendererBase.Telerik.Reporting.Processing.IRenderingExtension.Render(Report report, Hashtable renderingContext, Hashtable deviceInfo, CreateStream createStreamCallback, EvaluateHeaderFooterExpressions evalHeaderFooterCallback) +21
   Telerik.Reporting.Processing.ReportProcessor.Render(IList`1 reports, ExtensionInfo extensionInfo, Hashtable renderingContext, Hashtable deviceInfo, CreateStream createStreamCallback) +353
   Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, IReportDocument reportDocument, Hashtable deviceInfo, CreateStream createStreamCallback, String& documentName) +421
   Telerik.ReportViewer.WebForms.ServerReport.Render(HttpResponse response, String format, Int32 pageIndex) in ServerReport.cs:90
   Telerik.ReportViewer.WebForms.ReportExportOperation.PerformOperation(NameValueCollection urlQuery, HttpContext context) in ReportExportOperation.cs:23
   Telerik.ReportViewer.WebForms.HttpHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext context) in HttpHandler.cs:65
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75


Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3053

3 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 02 Dec 2009, 09:12 AM
Hi Dave,

Have you reviewed our documentation concerning the Medium Trust Support of Telerik Reporting? As we see from your stack trace, you're trying to export the report to PDF, and as stated in the latter article:

"The PDF and Excel rendering extensions require UnmanagedCode permission to operate at all times. Take that into consideration when deploying your application and if necessary disable those extensions to avoid security exceptions. For more information refer to Configuring Telerik Reporting help section."

All the best,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Dave Koppe
Top achievements
Rank 1
answered on 02 Dec 2009, 01:45 PM
So basically your saying to disable the option to export to pdf? Is there another way to export the reports to pdf in Medium Trust since the site is hosted in godaddy? My whole reason I wanted to go Telerik Reporting route was to export the report to pdf.

Thanks,

Dave K
0
Steve
Telerik team
answered on 02 Dec 2009, 04:22 PM
Hi Dave,

We believe there is some misunderstanding. Even if you disable the export option in the Report Viewer there is no way to render the report in pdf format, because this is limitation of the PDF rendering extension (i.e. it uses unmanaged functions that do not work in medium trust). Namely for the PDF to work in medium trust you should have UnmanagedCode permission. This permission is not allowed in Medium Trust environments by default and needs to be enabled additionally.
We do not believe that corporations like GoDaddy would agree to enable this permission for you, but it does not hurt to ask.
In all fairness, there is no other .NET Reporting product that supports export to PDF in Medium Trust (or at least we're not aware of such).

Best wishes,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Dave Koppe
Top achievements
Rank 1
Answers by
Steve
Telerik team
Dave Koppe
Top achievements
Rank 1
Share this question
or