Using custom fonts in a Docker container

Stimulsoft Reports.WEB discussion
Post Reply
smckec
Posts: 12
Joined: Mon Oct 22, 2018 3:04 pm

Using custom fonts in a Docker container

Post 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
Attachments
Dockerfile.txt
(668 Bytes) Downloaded 208 times
DummyReport.mrt
(582.63 KiB) Downloaded 277 times
ReportController.cs
(1.39 KiB) Downloaded 206 times
Lech Kulikowski
Posts: 6247
Joined: Tue Mar 20, 2018 5:34 am

Re: Using custom fonts in a Docker container

Post 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.
smckec
Posts: 12
Joined: Mon Oct 22, 2018 3:04 pm

Re: Using custom fonts in a Docker container

Post 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
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Using custom fonts in a Docker container

Post by Alex K. »

Hello,

We need some additional time to investigate the issue.

Thank you.
smckec
Posts: 12
Joined: Mon Oct 22, 2018 3:04 pm

Re: Using custom fonts in a Docker container

Post by smckec »

Hi,

Have you been able to investigate this issue further?

Thanks
Lech Kulikowski
Posts: 6247
Joined: Tue Mar 20, 2018 5:34 am

Re: Using custom fonts in a Docker container

Post by Lech Kulikowski »

Hello,

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

Thank you.
Post Reply