We are trying to migrate our project from Windows to Linux Containers and we came across an issue where given all the same parameters and same file, different PNG images are being generated on Windows and on Linux when using PngDevice.Process().
The interesting part is that the final PDF document that is generated on both OS’s looks identical but there is also a difference when comparing bytes. That is not really an issue to us since the final PDF looks identical, however the PNG images being generated on Linux look different and far worse than the ones generated on Windows. This is an issue since we display these PNGs to customers as they manipulate the document. This difference in images is more obvious when the document is zoomed in and everything appears more bold from Linux.
Please see the small sample project I’ve created with an included PDF document that reproduces this issue. Simply take the project, restore dependencies, and run on Windows, and then do the same on Linux to see the difference in outputs.
Another issue with this difference in output is that the images generated on Linux end up being 2.5X bigger while still being the same resolution as the ones generated on Windows.
I believe this is a bug and any help or work arounds to make the PNG image look the same is appreciated. I have already tried increasing the resolution on the PngDevice to 400 which makes it looks pretty similar but still lower quality than on Windows, and this increases the file size from 200kb on Windows to 1500kb on Linux which isn’t sustainable.
Also the only fonts being used in this document are the following, and I’ve made sure Microsoft’s TrueType fonts are installed in the Linux Container.
We have tested the scenario in our environment i.e. Linux (Ubuntu). We were unable to notice any issue in the output image. Are you facing this issue with every PDF file or just this specific document that you have shared?
Would you kindly make sure that the Microsoft Fonts are installed in “/usr/share/fonts/truetype/msttcorefonts” directory? Also, please try to upgrade the libgdiplus package to the latest version. Please feel free to let us know in case you still notice any issue by sharing complete details of your Linux environment (OS Name and Version).
I am facing this issue with every PDF I’ve tried so far (I’ve tried a couple), and those PDFs use other fonts as well like Helvetica which I believe should be defaulting to Arial.
I’m facing this issue on Ubuntu 18.04, however since you weren’t able to reproduce it I decided to make a fresh Ubuntu 20.04 installation to eliminate any environment variables. If it makes a difference I am running Ubuntu on top of WSL2 engine in Windows.
After I made a new Ubuntu 20.04 installation I ran the following commands to install .NET, libgdiplus, fontconfig, mscorefonts, and also I installed vista fonts just in case for Calibri.
We have logged an investigation ticket as PDFNET-49692 in our issue tracking system for further investigation on this scenario. We will further look into its details and let you know as soon as the ticket is resolved. Please be patient and spare us some time.
Can you please share what Linux environment and .NET Core version you guys used to test this and create the good looking image “Converted_Image_1.png” in your first reply?
Maybe we can use the same environment and version for now to produce good images while this is being investigated.
We tested in Ubuntu 15.04 x64 environment. We performed testing using both .NET and Java APIs and did not notice any issue. At the moment, the issue seems related to specific environment and that is why we logged a ticket for detailed investigation.
We are afraid that the earlier logged issue is not yet resolved. However, we have recorded your concerns and will surely inform you once the ticket is closed.
The issue is currently under the phase of the investigation and as soon as it is completed, we will be able to share some feedback in this forum thread. Please spare us some time.