Telerik Reporting PDF export fails when hosted on Docker

1 Answer 577 Views
Report Designer (standalone) Report Viewer - Blazor Rest Service
Jakub
Top achievements
Rank 1
Iron
Jakub asked on 13 Dec 2021, 04:33 PM
Hi,

I am using Telerik.Reporting library (15.2.21.1110) in Blazor Server application.
The report was created in standalone Report designer (.trdp).
I can display that report in the Blazor ReportViewer component. 
When running the web app on Windows I can export to PDF, DOCX via the ReportViewer and also without the REST service using Telerik.Reporting.Processing.ReportProcessor.RenderReport().


The problem occurs when building the application as Docker RedHat based image. 
In that case the DOCX works but the PDF fails in both scenarios (REST report service and ReportProcessor) throwing eventually System.OperationCanceledException.
Dockerfile instructs to use RedHat UBI8 base image and install GDI+ Win library replacement for Unix systems (glibc-devel, libicu, libX11-devel, libgdiplus).

Do you have any suggestions what could be wrong?



blazor.server.js:1 [2021-12-13T15:29:47.907Z] Error: System.OperationCanceledException: The operation was canceled.
   at System.Threading.CancellationToken.ThrowOperationCanceledException() in /builddir/build/BUILD/dotnet-9e8b04bbff820c93c142f99a507a46b976f5c14c/src/runtime.4822e3c3aa77eb82b2fb33c9321f923cf11ddde6/artifacts/source-build/self/src/src/libraries/System.Private.CoreLib/src/System/Threading/CancellationToken.cs:line 368
   at System.Threading.ManualResetEventSlim.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) in /builddir/build/BUILD/dotnet-9e8b04bbff820c93c142f99a507a46b976f5c14c/src/runtime.4822e3c3aa77eb82b2fb33c9321f923cf11ddde6/artifacts/source-build/self/src/src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs:line 550
   at System.Threading.Tasks.Task.SpinThenBlockingWait(Int32 millisecondsTimeout, CancellationToken cancellationToken) in /builddir/build/BUILD/dotnet-9e8b04bbff820c93c142f99a507a46b976f5c14c/src/runtime.4822e3c3aa77eb82b2fb33c9321f923cf11ddde6/artifacts/source-build/self/src/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:line 2979
   at System.Threading.Tasks.Task.InternalWaitCore(Int32 millisecondsTimeout, CancellationToken cancellationToken) in /builddir/build/BUILD/dotnet-9e8b04bbff820c93c142f99a507a46b976f5c14c/src/runtime.4822e3c3aa77eb82b2fb33c9321f923cf11ddde6/artifacts/source-build/self/src/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:line 2914
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) in /builddir/build/BUILD/dotnet-9e8b04bbff820c93c142f99a507a46b976f5c14c/src/runtime.4822e3c3aa77eb82b2fb33c9321f923cf11ddde6/artifacts/source-build/self/src/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:line 2710
   at System.Threading.Tasks.Task.Wait(CancellationToken cancellationToken) in /builddir/build/BUILD/dotnet-9e8b04bbff820c93c142f99a507a46b976f5c14c/src/runtime.4822e3c3aa77eb82b2fb33c9321f923cf11ddde6/artifacts/source-build/self/src/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:line 2648
   at Telerik.Reporting.Paging.PageCompositionBase.SeparateThreadOutputBehavior.Finish()
   at Telerik.Reporting.Paging.PageCompositionBase.CreatePages()
   at Telerik.Reporting.Paging.PagerBase.Telerik.Reporting.Paging.IPager.CreatePages(IPageHandler handler, LayoutElement root)
   at Telerik.Reporting.BaseRendering.RenderingExtensionBase.Render(LayoutElement root, Hashtable renderingContext, Hashtable deviceInfo, CreateStream createStreamCallback, EvaluateHeaderFooterExpressions evalHeaderFooterCallback, PageSettings pageSettings)
   at Telerik.Reporting.BaseRendering.RenderingExtensionBase.Render(Report report, Hashtable renderingContext, Hashtable deviceInfo, CreateStream createStreamCallback, EvaluateHeaderFooterExpressions evalHeaderFooterCallback)
   at Telerik.Reporting.Processing.ReportProcessor.RenderCore(ExtensionInfo extensionInfo, IList`1 processingReports, Hashtable deviceInfo, IRenderingContext renderingContext, CreateStream createStreamCallback)
   at Telerik.Reporting.Processing.ReportProcessor.ProcessAndRender(String format, ReportSource reportSource, Hashtable deviceInfo, IRenderingContext renderingContext, CreateStream createStreamCallback)
   at Telerik.Reporting.Processing.ReportProcessor.ProcessAndRenderStateless(String format, ReportSource reportSource, Hashtable deviceInfo, IRenderingContext renderingContext, CreateStream createStreamCallback)
   at Telerik.Reporting.Processing.ReportProcessor.<>c__DisplayClass46_0.<RenderReport>b__0(SingleStreamManager sm)
   at Telerik.Reporting.Processing.ReportProcessor.RenderReportSafe(Func`2 renderCallback, String format, IRenderingContext renderingContext)
   at Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, ReportSource reportSource, Hashtable deviceInfo, CancellationToken cancellationToken)
   at Telerik.Reporting.Processing.ReportProcessor.RenderReport(String format, ReportSource reportSource, Hashtable deviceInfo)
  

1 Answer, 1 is accepted

Sort by
1
Accepted
Jakub
Top achievements
Rank 1
Iron
answered on 15 Dec 2021, 12:03 PM

I got this one to work. The root cause turned out to be related to fonts.

I needed to manually install and specify the fonts to use when rendering my report. It needs to be done even though there was default system font dejavu installed in the Linux container. 

This documentation page describes the steps: https://docs.telerik.com/reporting/configuring-telerik-reproting-privatefonts 

The thing is that I would rather be reactive about it and have the Telerik tell me about the root cause in some logs than proactively looking for some clues of what might have gone wrong in the documentation.

Jonathan
Top achievements
Rank 1
commented on 20 Dec 2021, 03:18 PM

Thank you for posting this! I was encountering the same obscure exception trying to generate PDF reports in an AWS Lambda container before I had installed the fonts. You can avoid using the privatefonts configuration if you discover where to put the fonts for your Linux distro. For me, I copied my fonts into a folder named /usr/share/fonts/truetype and then ran fc-cache -svf to update the font config cache. This requires the fontconfig package to be installed in the container.

The pertinent parts of my Dockerfile are:

COPY fonts /usr/share/fonts/truetype
RUN yum install -y -d1 libgdiplus fontconfig
RUN fc-cache -svf

The fonts folder I'm copying from contains the TTF files for the fonts of my reports that I want to generate PDFs of.
Tags
Report Designer (standalone) Report Viewer - Blazor Rest Service
Asked by
Jakub
Top achievements
Rank 1
Iron
Answers by
Jakub
Top achievements
Rank 1
Iron
Share this question
or