Difference in exported PDF on Linux vs Windows

Stimulsoft Reports.NET discussion
janek
Posts: 6
Joined: Fri Jun 26, 2020 12:09 pm

Difference in exported PDF on Linux vs Windows

Post by janek »

Hello,

I've used the nuget-Packages Stimulsoft.Reports.Engine.NetCore and Stimulsoft.Reports.Web.NetCore to export the SimpleList example as PDF.
This was done on a Windows machine running Windows 10 and in a VM running on Ubuntu 18.04.

The result is two slightly different looking PDFs, as in the character width seems to differ.
The project uses .Net Core 3.1 and I've used StiFontCollection.AddFontFile() as well to make sure they use the same font.

A similar problem was experienced when trying to create a report at runtime using this sample.
The produced PDFs had big differences, the size of the boxes was significantly greater when exported on Linux.

We are considering using your product for report generation, and a necessary workflow is designing a report on Windows but rendering on a different machine using Linux.

The produced files of the former case are attached. I can try to provide the results of the latter case as well, if that is helpful. Thanks in advance for any help.
Attachments
result_linux.pdf
(911.22 KiB) Downloaded 264 times
result.pdf
(911.32 KiB) Downloaded 233 times
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: Difference in exported PDF on Linux vs Windows

Post by Lech Kulikowski »

Hello,

We need some additional time to investigate the issue, we will let you know about the result.

Thank you.
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: Difference in exported PDF on Linux vs Windows

Post by Lech Kulikowski »

Hello,

> The result is two slightly different looking PDFs, as in the character width seems to differ.
> The project uses .Net Core 3.1 and I've used StiFontCollection.AddFontFile() as well to make sure they use the same font.

In Windows and in Linux different methods of character size determination are used, so the width of characters may vary. We added correction factors to make it look similar.
But in each new version of NetCore the built-in graphics library changes, and at the moment new correction factors are necessary.

we see from your files that in Linux the width of symbols is less by about 4%. can you check that this is true for all fonts, or for each font you need different values?

> A similar problem was experienced when trying to create a report at runtime using this sample.
> The produced PDFs had large, the size of the boxes was significantly larger when on Linux.

Please send us a samples for analysis.

Thank you.
janek
Posts: 6
Joined: Fri Jun 26, 2020 12:09 pm

Re: Difference in exported PDF on Linux vs Windows

Post by janek »

> we see from your files that in Linux the width of symbols is less by about 4%. can you check that this is true for all fonts, or for each font you need different values?

When checking with Times New Roman width difference appears to be around the same, although hard to determine. But there also seems to be a height difference now, as can be seen in the attached files where as with Arial only width was different.


>> A similar problem was experienced when trying to create a report at runtime using this sample.
>> The produced PDFs had large, the size of the boxes was significantly larger when on Linux.
>
>Please send us a samples for analysis.

Welp, I just tried to reproduce it but this time it worked correctly(except for the font differences of course), not sure where I went wrong when I tried it the first time.

Will I have to wait for a new release until the font problems get fixed?
Attachments
result_timesnewroman_linux.pdf
(1.14 MiB) Downloaded 210 times
result_timesnewroman.pdf
(1.14 MiB) Downloaded 231 times
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: Difference in exported PDF on Linux vs Windows

Post by Lech Kulikowski »

Hello,

We need some additional time to investigate the issue, we will let you know about the result.

Thank you.
jhonalkaiser
Posts: 3
Joined: Tue May 12, 2020 3:47 pm

Re: Difference in exported PDF on Linux vs Windows

Post by jhonalkaiser »

Hello, since I'm having the same problem I thought I would post details here in case it helps with the investigation.

My team uses .NET Core to render PDF of .MRT files inside a Docker container and the Arial font looks really different between Linux and Windows (see attachment).

This is how I load all TTF font files from a directory:

Code: Select all

string[] files = Directory.GetFiles("fonts_directory");
foreach (string file in files)
{
	if (file.ToLower().EndsWith(".ttf"))
	{
		Console.WriteLine("Loading font " + file);
		var fullPath = Path.GetFullPath(file);
		Stimulsoft.Base.StiFontCollection.AddFontFile(fullPath);
	}
}
And this is roughly how I generate the PDF file:

Code: Select all

var report = StiReport.CreateNewReport();
// ...
// ... MRT loading code and data binding
// ...
return StiNetCoreReportResponse.ResponseAsPdf(report);
On top of that I made the container install mscorefonts for good measure by adding these lines:

Code: Select all

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
...
RUN sed -i'.bak' 's/$/ contrib/' /etc/apt/sources.list
RUN apt-get update && apt-get install -y --no-install-recommends libgdiplus libc6-dev ttf-mscorefonts-installer fontconfig
...
As you can see from the attachments, the PDF is rendered with a very weird font on the Docker container.
And checking what fonts are embeded in the PDF file using a service like: https://www.pdfconvertonline.com/extrac ... nline.html tells me Arial and Arial Bold ttfs are in fact present inside it.

Note: These PDFs have "trial" watermark because they were generated in development environment. We do have the license in production.
Attachments
linux-report.pdf
(153.62 KiB) Downloaded 222 times
windows-report.pdf
(865.71 KiB) Downloaded 214 times
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: Difference in exported PDF on Linux vs Windows

Post by Lech Kulikowski »

Hello,

We need some additional time to investigate the issue, we will let you know about the result.

Thank you.
n.froeh
Posts: 17
Joined: Mon Oct 05, 2020 6:03 am

Re: Difference in exported PDF on Linux vs Windows

Post by n.froeh »

Hello,

is there any update on this issue?

We're checking if Stimulsoft Reporting meets our requirements as our new reporting engine. Right now we design our report template on a local Windows system (.mrt). The report later is rendered within our application with different data on an Ubuntu system (packed document) and delivered to our users.

As described by my fellow contributors the report rendered on the linux system and the report rendered on the windows system look completely different (see attachments "BelegWin" for Windows, "BelegLinux" for Ubuntu system).

Is it possible to "pre-render" a report on the windows system, change the data within the app at the linux system and retrieve the accurate rendered report with the updated data on the linux system (programatically)?

Or will there be a fix/workaround in one of the upcoming versions?

edit: The biggest issue for us are the random word-wraps and line gaps between text components (the difference in local setting was expected).

Thank you and have a nice day.
Attachments
BelegWin.pdf
(92.59 KiB) Downloaded 175 times
BelegLinux.pdf
(95.14 KiB) Downloaded 187 times
Beleg.mrt
(60.83 KiB) Downloaded 128 times
Beleg.json
(3.11 KiB) Downloaded 134 times
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: Difference in exported PDF on Linux vs Windows

Post by Lech Kulikowski »

Hello,

We have been doing research and found out the following.
All work with graphics in NetFramework goes through the GDI+ graphics library.
On Win and Linux this library works differently, it uses different sets of font parameters, so the height of the line is different.
Now we are working on our font engine which will parse fonts equally on all systems. If there are no unexpected problems, it will work in a month or two.

Thank you.
hosecloud.com
Posts: 13
Joined: Thu Mar 05, 2020 9:47 am

Re: Difference in exported PDF on Linux vs Windows

Post by hosecloud.com »

Lech Kulikowski wrote: Mon Oct 05, 2020 1:47 pm Hello,

We have been doing research and found out the following.
All work with graphics in NetFramework goes through the GDI+ graphics library.
On Win and Linux this library works differently, it uses different sets of font parameters, so the height of the line is different.
Now we are working on our font engine which will parse fonts equally on all systems. If there are no unexpected problems, it will work in a month or two.

Thank you.
it's ready ?
Post Reply