none
ReportViewer Control on Azure Web Sites - Export to PDF not working RRS feed

  • Question

  • Hello

    I am publishing a web application with a reportviewer control on an azure web site.

    So far I figured out that I had to add references to the Microsoft.reportViewer.common, Microsoft.reportViewer.WebForms and Microsoft.reportViewer.ProcessingObjectModel DLLs with Copy Local set to true, because the azure web site do not have those in the GAC. I am using version 12.0.0.0 of those DLLS and I have built the project with VS 2015 targeting .NET Framework 4.6.1

    The Control is rendering the report. I can export the report in Excel and Word but export to PDF is not working. Stack trace is:

    [ArgumentException: Parameter is not valid.]
       System.Drawing.Graphics.GetHdc() +1138213
       Microsoft.ReportingServices.Rendering.RichText.LineBreaker.Flow(TextBox textBox, Graphics g, FontCache fontCache, FlowContext flowContext, Boolean keepLines, Single& height) +70
       Microsoft.ReportingServices.Rendering.RichText.TextBox.MeasureFullHeight(TextBox textBox, Graphics g, FontCache fontCache, FlowContext flowContext, Single& contentHeight) +496
       Microsoft.ReportingServices.Rendering.HPBProcessing.TextBox.CalculateVerticalSize(PageContext pageContext) +359
       Microsoft.ReportingServices.Rendering.HPBProcessing.TextBox.DetermineVerticalSize(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, List`1 ancestors, Boolean& anyAncestorHasKT, Boolean hasUnpinnedAncestors) +32
       Microsoft.ReportingServices.Rendering.HPBProcessing.PageItem.CalculateVertical(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, PageItem[] siblings, List`1 ancestors, Boolean& anyAncestorHasKT, Boolean hasUnpinnedAncestors, Nullable`1 sourceWidth) +721
       Microsoft.ReportingServices.Rendering.HPBProcessing.RowInfo.CalculateVerticalLastDetailCell(PageContext context, Boolean firstTouch, Boolean delayCalc) +411
       Microsoft.ReportingServices.Rendering.HPBProcessing.Tablix.CreateDetailCell(Tablix tablix, TablixMember colMemberParent, Int32 colGridIndex, RowInfo rowInfo, PageContext pageContext) +907
       Microsoft.ReportingServices.Rendering.HPBProcessing.Tablix.TraverseColumnMembers(Tablix tablix, TablixMember colMemberParent, Int32 parentColIndex, RowInfo currRowInfo, Boolean create, Double startInTablix, Double endInTablix, Int32& detailCellIndex, Int32& visibleSpan, List`1 detailCellsState, PageContext pageContext) +107
       Microsoft.ReportingServices.Rendering.HPBProcessing.Tablix.TraverseColumnMembers(Tablix tablix, TablixMember colMemberParent, Int32 parentColIndex, RowInfo currRowInfo, Boolean create, Double startInTablix, Double endInTablix, Int32& detailCellIndex, Int32& visibleSpan, List`1 detailCellsState, PageContext pageContext) +878
       Microsoft.ReportingServices.Rendering.HPBProcessing.Tablix.CreateDetailRow(Tablix tablix, TablixMember rowMemberParent, Int32 parentRowIndex, Int32 parentColIndex, PageContext pageContext) +250
       Microsoft.ReportingServices.Rendering.HPBProcessing.Tablix.CreateRowMemberChildren(Tablix tablix, TablixMember rowMemberParent, Int32 defTreeLevel, Boolean parentBorderHeader, Int32 parentRowIndex, Int32 parentColIndex, Int32 sourceIndex, Boolean resetContext, Boolean parentHasFooters, LevelInfo parentLevelInfo, PageContext pageContext) +136
       Microsoft.ReportingServices.Rendering.HPBProcessing.Tablix.CreateRowMemberChildren(Tablix tablix, TablixMember rowMemberParent, Int32 defTreeLevel, Boolean parentBorderHeader, Int32 parentRowIndex, Int32 parentColIndex, Int32 sourceIndex, Boolean resetContext, Boolean parentHasFooters, LevelInfo parentLevelInfo, PageContext pageContext) +2930
       Microsoft.ReportingServices.Rendering.HPBProcessing.Tablix.CreateTablixRows(Tablix tablix, TablixMember rowMemberParent, Int32 defTreeLevel, Boolean parentBorderHeader, Int32 parentRowIndex, Int32 parentColIndex, List`1& pageStructMemberCell, Boolean ignoreTotals, Boolean& finishLevel, Boolean parentHasFooters, CreateItemsContext createItems, Double startInTablix, Double endInTablix, PageContext pageContext) +2763
       Microsoft.ReportingServices.Rendering.HPBProcessing.Tablix.CreateTablixItems(Tablix tablix, PageContext pageContext, CreateItemsContext createItems, Double startInTablix, Double endInTablix) +113
       Microsoft.ReportingServices.Rendering.HPBProcessing.Tablix.CreateVertically(PageContext pageContext, CreateItemsContext createItems, Double startInTablix, Double endInTablix, Double topInParentSystem) +293
       Microsoft.ReportingServices.Rendering.HPBProcessing.Tablix.DetermineVerticalSize(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, List`1 ancestors, Boolean& anyAncestorHasKT, Boolean hasUnpinnedAncestors) +614
       Microsoft.ReportingServices.Rendering.HPBProcessing.PageItem.CalculateVertical(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, PageItem[] siblings, List`1 ancestors, Boolean& anyAncestorHasKT, Boolean hasUnpinnedAncestors, Nullable`1 sourceWidth) +721
       Microsoft.ReportingServices.Rendering.HPBProcessing.PageItemContainer.DetermineContentVerticalSize(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, List`1 ancestors, Boolean& anyAncestorHasKT, Boolean hasUnpinnedAncestors, Boolean resolveState, Boolean resolveItem) +321
       Microsoft.ReportingServices.Rendering.HPBProcessing.PageItemContainer.DetermineVerticalSize(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, List`1 ancestors, Boolean& anyAncestorHasKT, Boolean hasUnpinnedAncestors) +151
       Microsoft.ReportingServices.Rendering.HPBProcessing.PageItem.CalculateVertical(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, PageItem[] siblings, List`1 ancestors, Boolean& anyAncestorHasKT, Boolean hasUnpinnedAncestors, Nullable`1 sourceWidth) +721
       Microsoft.ReportingServices.Rendering.HPBProcessing.PageItem.CalculateVertical(PageContext pageContext, Double topInParentSystem, Double bottomInParentSystem, PageItem[] siblings, List`1 ancestors, Boolean& anyAncestorHasKT, Boolean hasUnpinnedAncestors) +53
       Microsoft.ReportingServices.Rendering.HPBProcessing.ReportSection.NextPage(RPLWriter rplWriter, Int32 pageNumber, Int32 totalPages, Double top, Double availableHeight, ReportSection nextSection, Boolean isFirstSectionOnPage) +1011
       Microsoft.ReportingServices.Rendering.HPBProcessing.Report.NextPage(RPLWriter rplWriter, Int32 totalPages) +379
       Microsoft.ReportingServices.Rendering.HPBProcessing.HPBProcessing.GetNextPage(RPLReport& rplReport) +325
       Microsoft.ReportingServices.Rendering.ImageRenderer.PDFRenderer.Render(Report report, NameValueCollection deviceInfo, Hashtable renderProperties, CreateAndRegisterStream createAndRegisterStream) +640
       Microsoft.ReportingServices.Rendering.ImageRenderer.RendererBase.Render(Report report, NameValueCollection reportServerParameters, NameValueCollection deviceInfo, NameValueCollection clientCapabilities, Hashtable& renderProperties, CreateAndRegisterStream createAndRegisterStream) +61

    [LocalProcessingException: An error occurred during local report processing.]
       Microsoft.Reporting.WebForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, PageCountMode pageCountMode, CreateAndRegisterStream createStreamCallback, Warning[]& warnings) +167
       Microsoft.Reporting.WebForms.LocalModeSession.RenderReport(String format, Boolean allowInternalRenderers, String deviceInfo, NameValueCollection additionalParams, Boolean cacheSecondaryStreamsForHtml, String& mimeType, String& fileNameExtension) +193
       Microsoft.Reporting.WebForms.ExportOperation.PerformOperation(NameValueCollection urlQuery, HttpResponse response) +154
       Microsoft.Reporting.WebForms.HttpHandler.ProcessRequest(HttpContext context) +240
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +188
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

    Monday, April 25, 2016 12:15 PM

All replies

  • Hi Pascal,

    Thank you for your question. 

    I am trying to involve someone more familiar with this topic for a further look at this issue. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated. 

    Thank you for your understanding and support.

    Best Regards,
    Qiuyun Yu


    Qiuyun Yu
    TechNet Community Support


    Tuesday, April 26, 2016 9:08 AM
    Moderator
  • Any news on this ?

    To he Microsoft Folks,is this a known issue on Azure Web Sites ?

    Friday, May 13, 2016 12:50 PM
  • Hi Pascal,

    Yes, this is a known issue on Azure Websites, you may hit this issue if you are using a Free app service plan.

    Select any paid app service plan could avoid this issue.

    The full explanation is documented at the GitHub.com (https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#win32ksys-user32gdi32-restrictions)

    Quote:

    Win32k.sys (User32/GDI32) Restrictions

    For the sake of radical attack surface area reduction, the sandbox prevents almost all of the Win32k.sys APIs from being called, which practically means that most of User32/GDI32 system calls are blocked. For most applications this is not an issue since most Azure Web Apps do not require access to Windows UI functionality (they are web applications after all).

    However one common pattern that is affected is PDF file generation. There are several cases of note:

    Microsoft SQL Reporting Framework manually generating PDFs

    This usage pattern does not work for Free/Shared plans due to the sandbox. However, a small set of APIs are opened for use in Basic+ plans; these APIs are designed to enable SQL Reporting framework creation of PDFs. So these libraries should be usable for PDF generation in Basic+.

    PDF generation from HTML

    There are multiple libraries used to convert HTML to PDF. Many Windows/.NET specific versions leverage IE APIs and therefore leverage User32/GDI32 extensively. These APIs are largely blocked in the sandbox (regardless of plan) and therefore these frameworks do not work in the sandbox.

    There are some frameworks that do not leverage User32/GDI32 extensively (wkhtmltopdf, for example) and we are working on enabling these in Basic+ the same way we enabled SQL Reporting.

    Tuesday, May 17, 2016 9:05 AM