Problem with fonts on Docker/Kubernetes/Linux

2 Answers 767 Views
.NET Core Report Designer - Web
LLCD
Top achievements
Rank 1
Iron
LLCD asked on 13 Oct 2023, 09:37 AM | edited on 18 Oct 2023, 11:05 AM

Hello.
Currently I am designing a report, very simple report like below.
I'm using Web report designer written in Razor pages (.NET 6)
I run the Web report designer on Linux (docker/kubernetes) and on Windows (IIS)

The properties of two textBoxes (marked above textBox40 and textBox42) are like below

on Linux

The report preview looks like this

In the preview above, the word "przekroczenia" (exceedance in Polish) has been cut off but should be moved to a new line.

After exporting the report to XLSX

In the preview above, after exporting the report to XLSX, the letters are cut off.

After exporting the same report to PDF, it looks like this

In the preview above, after exporting the report to PDF, there is no spaces and there is no text wrapping.

on Windows

The report preview looks like this

In the preview above, everything looks good.

After exporting the report to XLSX

In the preview above, after exporting the report to XLSX, the letters are cut off.

After exporting the same report to PDF, it looks like this

In the preview above, everything looks good.

My appsetting.json file contains

"telerikReporting": {
  "extensions": [
    {
      "name": "PDF",
      "parameters": [
        {
          "name": "FontEmbedding",
          "value": "None"
        }
      ]
    }
  ]
}

I have tried all options related to FontEmbeddingFull, Subset, None and the result is always the same.
The only thing that changes is the PDF file size (and this is logical).

What should I set in order to fix all errors.
Report exported to XLSX on Windows and Linux looks the same badly. The letters are cut off.
Report exported to PDF on Linux looks very bad. There is no spaces and there is no text wrapping.
Report exported to PDF on Windows looks good.

Regards!

2 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 16 Oct 2023, 08:57 AM

Hello Bartłomiej,

Thank you for the attached screenshots and the additional information!

Besides the files provided here, you also sent me the TRDP file in a support ticket and I was able to render the report in the XLSX and PDF rendering extensions on both Windows and Linux(through Docker) environments. I have attached the results of my local tests to this reply, please have a look.

In summary, I was unable to reproduce the problem where the text is cut off in either scenario. Although there are some differences in the Linux and Windows rendering, all of the text was rendered correctly and the size of the table cells was the same as in the designed report.

I tested using a .NET 6 ASP.NET Core project and Telerik Reporting of version 17.1.23.718 - Telerik Reporting - Progress® Telerik® Reporting R2 2023 SP1 (17.1.23.718). Which version of Telerik Reporting did you use to produce the problematic Excel and PDF renderings? If you used an older version, please update to the 17.1.23.718 version and see if that resolves the problem. You may also try to install version 6.0.0 of the System.Drawing.Common package.

Besides the problem being related to the versions, another possible reason for the difference in how the report rendered on my machine and in your tests is that the font used in the report may be missing on your Linux Docker image. The font 'Arial' is often not installed by default and when it is not present on the machine, our engine substitutes it with the default font for the OS which may lead to strange renderings. Please install the font on your Docker image - How to Install Microsoft Truetype Fonts in Linux - Make Tech Easier, or reference the font locally in your project through privateFonts - Configuring the privateFonts Element - Telerik Reporting.

Please test those changes and let me know how it goes. If you need further assistance, please try to prepare a sample project that I can use to reproduce the issue locally. I will be looking forward to receiving an update from you.

Regards,
Dimitar
Progress Telerik

Stay tuned by visiting our roadmap and feedback portal pages, enjoy a smooth take-off with our Getting Started resources, or visit the free self-paced technical training at https://learn.telerik.com/.
0
LLCD
Top achievements
Rank 1
Iron
answered on 18 Oct 2023, 09:20 AM | edited on 18 Oct 2023, 12:57 PM

Hello Dimitar,

Thank you for your reply!

First of all I decided to update Telerik Reporting.
I was using older version 16.2.22.1109. 
Now I am using version 17.1.23.718 but it not resolved my problem.
Please, take a look at project dependencies

I am using Telerik Kendo UI v2022.3.1109

Also I set font of all textBoxes in the report to Arial. It was set previously but I set it once again.

From the proposed solutions, I chose privateFonts.
I have attached the font files to the project.

Next I have build new docker-image
I have checked if fonts are available inside docker-image.

Here is my docker-image, as you see fonts are available inside image (inside container).

Section telerikReporting inside appsettings.json file is like below

"telerikReporting": {
  "extensions": [
    {
      "name": "XLSX",
      "parameters": [
        {
          "name": "UseExtendedFormatting",
          "value": "False"
        }
      ]
    },
    {
      "name": "PDF",
      "parameters": [
        {
          "name": "FontEmbedding",
          "value": "Full"
        }
      ]
    }
  ],
  "privateFonts": [
    {
      "fontFamily": "Arial",
      "path": "~/wwwroot/resources/fonts/arialbd.ttf",
      "fontStyle": "Bold"
    },
    {
      "fontFamily": "Arial",
      "path": "~/wwwroot/resources/fonts/arialbi.ttf",
      "fontStyle": "Bold,Italic"
    },
    {
      "fontFamily": "Arial",
      "path": "~/wwwroot/resources/fonts/ariali.ttf",
      "fontStyle": "Italic"
    },
    {
      "fontFamily": "Arial",
      "path": "~/wwwroot/resources/fonts/arial.ttf"
    }
  ]
}

As you see I have set privateFonts and also I have set FontEmbedding at section extensions.
After that I run my project TelerikReportDesigner locally on IIS (on Windows) and on Docker (on Linux).

Please, take a look at report preview on both operating system.

I have exported report to PDF file, please see the result

In both cases font is embedded inside PDF file but what is very curious, two files have different size.


What should I set in order to fix all errors.
I need my report to look the same on IIS (Windows) and on Docker (Linux).
On Windows PDF file looks ok but on Linux PDF file looks terrible ... :( (see pdf-on-linux.png)

Regards!
Dimitar
Telerik team
commented on 19 Oct 2023, 08:08 AM

Hello Bartłomiej,

It seems that all the setups are correct and the font is getting successfully embedded in the PDF which should have been enough to render the report in the same way as in my local tests with rendering on Linux. The version of Telerik Reporting is also the same as what I tested with which leaves two possibilities for the differences:

  • The report that you are currently testing with is different from the one that was sent in the ticket
  • The different Linux image that you are using is somehow affecting the rendering result

Can you please confirm that you are not testing with an older/version of the report than what you sent me to test within the ticket? 

Also, did you test installing version 6.0.0 of the System.Drawing.Common? If you haven't, please do so and let me know if that helps.

With the Progress® Telerik® Reporting R3 2023 (17.2.23.1010) release, we introduced a new graphics engine - Skia, which is the default for Linux. I suspect that using this version, the report will be rendered correctly even on Linux, however, the downside is that it currently supports only PDF and HTML rendering which means that you would not be able to export reports to XLSX. If the latter is not important for you though, I recommend upgrading a giving Skia a try.

If you need further assistance, please try to send me a runnable project with a Dockerfile that I can use to reproduce the problem locally and see if there is a workaround.

I will be looking forward to your next update.

 

LLCD
Top achievements
Rank 1
Iron
commented on 23 Oct 2023, 08:00 AM | edited

Hello Dimitar,

In the first place I decided to update Progress® Telerik® Reporting to version 17.2.23.1010.
I checked if version was updated correctly by sending a request to endpoint https://localhost:5503/api/reportdesigner/version (I run my report-service on port 5503).

I got this result (picture below)

As you see I have the newest version of Progress® Telerik® Reporting.

Then (after update) I got a lot of errors and had to do a lot of research but luckily I found the article Future of Linux support for reporting.
I also found a video https://feedback.telerik.com/attachment/download/1119054 with step by step instructions on how to run Telerik® Reporting with Skia engine.

A few hours later the reports were working like a charm :)
On Linux and Windows I have the same expected result. The report looks the same in both environments and everything looks fine.

But....the only possible export to PDF is not what satisfies me and my boss :)
We have to back to older version 
17.1.23.718

I have one more question.
Do you have any information about when (approximately) the remaining formats (XLSX and DOCX) will be supported?
Greet and wait for a reply

LLCD
Top achievements
Rank 1
Iron
commented on 23 Oct 2023, 11:17 AM | edited

Hi Dimitar,
I would like to answer your questions from your comment above.

You asked me about two possibilities for the differences:

The report that you are currently testing with is different from the one that was sent in the ticket

The different Linux image that you are using is somehow affecting the rendering result

In the ticket I have attached the same report that I use locally.
I've attached it again just in case :) (file: EksportWyliczenia.zip)

I have only one docker image with my service TelerikReportDesigner.
This image is running on Docker Desktop for Windows.
When I run container with this image and when I execute command

cat /etc/os-release

inside this container I get

PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

When I run

cat /proc/version

I get

Linux version 5.15.90.1-microsoft-standard-WSL2 (oe-user@oe-host) (x86_64-msft-linux-gcc (GCC) 9.3.0, GNU ld (GNU Binutils) 2.34.0.20200220) #1 SMP Fri Jan 27 02:56:13 UTC 2023

Also I have instaled 
   - libc6-dev
    - libgdiplus
    - libx11-dev
    - ttf-mscorefonts-installer
    - fontconfig

You have also asked me about installed version of System.Drawing.Common.
My project is written in .NET6 so I have System.Drawing.Common version 6.0.0
I have attached System.Drawing.Common in project dependencies.

I will be looking forward to your next update.

Dimitar
Telerik team
commented on 26 Oct 2023, 07:18 AM

Hello BartÅ‚omiej,

Indeed, the Skia graphics engine introduced with R3 2023 supports only PDF and HTML rendering currently. We plan to implement the OpenXML formats(DOCX, XLSX, and PPTX) with the next PI release later this year or with the R1 release next year.

Back to exporting with the older version, I also used Docker Desktop to run the previously attached report in a Linux environment.  checked to see if my Linux image was any different from yours and this is what was returned:

# cat /proc/version
Linux version 5.15.90.1-microsoft-standard-WSL2 (oe-user@oe-host) (x86_64-msft-linux-gcc (GCC) 9.3.0, GNU ld (GNU Binutils) 2.34.0.20200220) #1 SMP Fri Jan 27 02:56:13 UTC 2023
# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
# 

And this is how my Dockerfile looks:

#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
WORKDIR /app

RUN apt-get update \
    && apt-get install -y --allow-unauthenticated \
        libc6-dev \
        libgdiplus \
        libx11-dev \
    && rm -rf /var/lib/apt/lists/*

#Install default MS fonts.
RUN apt-get update; apt-get install -y fontconfig

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["ConsoleApp1/ConsoleApp1.csproj", "ConsoleApp1/"]
RUN dotnet restore "ConsoleApp1/ConsoleApp1.csproj"
COPY . .
WORKDIR "/src/ConsoleApp1"
RUN dotnet build "ConsoleApp1.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "ConsoleApp1.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "ConsoleApp1.dll"]

It seems that we even use the same Linux image so I honestly have no clue why we get a different rendering result for the same report. Would it be possible to send your project or a sample one that I can use to reproduce the issue locally?

Additionally, is it an option for you to use a Windows image instead of Linux? If yes, please go with that route as rendering on Linux is known to have issues with the libgdiplus graphics engine, for more details - Deploying on Linux.

 

Tags
.NET Core Report Designer - Web
Asked by
LLCD
Top achievements
Rank 1
Iron
Answers by
Dimitar
Telerik team
LLCD
Top achievements
Rank 1
Iron
Share this question
or