GDI+ Error or OutOfMemoryException on Exporting or Printing Telerik Report from Azure Web Apps
Environment
Product | Progress® Telerik® Reporting |
Deployment Environment | Azure |
Rendering Format | PDF, XLSX, DOCX, PPTX, RTF |
Description
Exporting Telerik reports to PDF and OpenXML formats deployed to Azure Web Apps may result in OutOfMemoryException
or Generic GDI+ Error
.
The issue affects also the print operation, which relies on the PDF rendering mechanism.
Error Message
System.OutOfMemoryException: Out of memory...
Cause
The reason for the error is that Windows Azure Web Apps restricts applications from accessing some system resources, including the GDI APIs, and rendering extensions such as PDF, PPTX, DOCX, XLSX, RTF, etc. would not be able to produce a document.
Solution
- Use Azure Web Role to host the application or the module handling the report processing and rendering e.g., switch to
Azure Cloud Service
or other plan. -
Use Azure Web Apps - Basic and Standard modes only. As of July 2014, Microsoft released an update allowing applications hosted in Azure Web Apps to generate PDF, Excel, Word, PowerPoint, and RTF files. If the reports contain a Barcode, Map, Graph item, or other rendered as a Metafile(EMF), you will need to turn off the usage of Metafile and use Bitmap.
For the purpose:
- Declare Telerik.Reporting Section
-
Add the setting for the DOCX, PPTX, XLSX, and RTF rendering extensions:
<configuration> <configSections> <section name="Telerik.Reporting" type="Telerik.Reporting.Configuration.ReportingConfigurationSection, Telerik.Reporting" allowLocation="true" allowDefinition="Everywhere"/> </configSections> … <Telerik.Reporting> <Extensions> <Render> <Extension name="DOCX" > <Parameters> <Parameter name="UseMetafile" value="false"/> </Parameters> </Extension> <Extension name="XLSX" > <Parameters> <Parameter name="UseMetafile" value="false"/> </Parameters> </Extension> <Extension name="PPTX" > <Parameters> <Parameter name="UseMetafile" value="false"/> </Parameters> </Extension> <Extension name="RTF" > <Parameters> <Parameter name="UseMetafile" value="false"/> </Parameters> </Extension> </Render> </Extensions> </Telerik.Reporting> … </configuration>
{ "telerikReporting": { "extensions": [ { "name": "DOCX", "parameters": [ { "Name": "UseMetafile", "Value": false } ] }, { "name": "PPTX", "parameters": [ { "Name": "UseMetafile", "Value": false } ] }, { "name": "XLSX", "parameters": [ { "Name": "UseMetafile", "Value": false } ] } ] } }