New to Telerik Reporting? Download free 30-day trial

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

Description

Exporting Telerik reports to PDF and Excel formats deployed to Azure Web Apps may result in OutOfMemoryException.

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 application from accessing some system resources, including the GDI API, and rendering extensions such as PDF would not be able to produce a document.

Solution

  1. 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.

  2. 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 and Excel files. If the reports contain Barcode, Map, Graph item or other rendered as a Metafile(EMF), you will need to turn of the usage of Metafile and use Bitmap.

For the purpose:

<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>
In this article