Page 1 of 1

Using custom fonts in a Docker container

Posted: Mon Nov 12, 2018 3:39 pm
by smckec
Hi,

I am using the Reports.Web.NetCore package (v2018.3.2) in a .NET Core web API that I am trying to run within a Linux Docker container. This seems to work fine until I try to use custom fonts, at which point I get the following error being thrown:

Code: Select all

System.NotSupportedException: Could not open display (X-Server required. Check your DISPLAY environment variable)
   at System.Drawing.Graphics.FromHwnd(IntPtr hwnd)
   at Stimulsoft.Report.Export.PdfFonts.GetFontMetricsFullTrust(Font font, PdfFontInfo currentFontInfo, UInt16[] glyphMap, Boolean isWpf)
   at Stimulsoft.Report.Export.PdfFonts.GetFontMetrics(Font font, PdfFontInfo currentFontInfo, UInt16[] glyphMap, Boolean isWpf)
   at Stimulsoft.Report.Export.PdfFonts.InitFontsData(Boolean isWpf)
   at Stimulsoft.Report.Export.StiPdfExportService.ExportPdf1(StiReport report, Stream stream, StiPdfExportSettings settings)
   at Stimulsoft.Report.Export.StiPdfExportService.ExportPdf(StiReport report, Stream stream, StiPdfExportSettings settings)
   at Stimulsoft.Report.Mvc.StiNetCoreReportResponse.ResponseAsPdf(StiReport report, StiPdfExportSettings settings, Boolean saveFileDialog)
   at DummyApi.Controllers.ReportController.Get() in /app/Controllers/ReportController.cs:line 19
Unfortunately I don't have a huge amount of experience with Docker and containerization - does anyone know what packages/dependencies are required in order for custom fonts to work in a Linux container?

I've attached the ReportController.cs class that generates the report, as well as the .mrt report file itself and my Dockerfile.

Thanks,

Sam

Re: Using custom fonts in a Docker container

Posted: Tue Nov 13, 2018 12:36 pm
by Lech Kulikowski
Hello,

That option only for windows systems
StiOptions.Export.Pdf.AllowImportSystemLibraries = true;

in your case, you should remove it or set to false.

Thank you.

Re: Using custom fonts in a Docker container

Posted: Tue Nov 13, 2018 2:27 pm
by smckec
Lech Kulikowski wrote: Tue Nov 13, 2018 12:36 pm Hello,

That option only for windows systems
StiOptions.Export.Pdf.AllowImportSystemLibraries = true;

in your case, you should remove it or set to false.

Thank you.
Thanks, that has stopped the errors that were showing previously - however the custom fonts are now not displaying in the exported PDF. Is there another flag I need to set in order to enable custom font rendering on a Linux system?

Thank you,

Sam

Re: Using custom fonts in a Docker container

Posted: Sat Nov 17, 2018 6:48 pm
by Alex K.
Hello,

We need some additional time to investigate the issue.

Thank you.

Re: Using custom fonts in a Docker container

Posted: Mon Dec 03, 2018 1:11 pm
by smckec
Hi,

Have you been able to investigate this issue further?

Thanks

Re: Using custom fonts in a Docker container

Posted: Tue Dec 04, 2018 2:13 pm
by Lech Kulikowski
Hello,

Unfortunately, we still couldn't say something about the issue with Linux Docker container.

Thank you.