ASPOSE R22.8 , NET6 fails PDF generation for LINUX (windows works)

We have recently updated our aspose library to R22.8 because of a .NET 6 migration, but are encountering severe errors with the library.

Seems like this issue is happening only in Linux while Windows works:
Our test environment OS is ubuntu focal with .net 6 SDK

Test method XXXX.XXX.XXX.Output.UnitTests.Aspose.PdfDocumentGenerationTests.CanGeneratePdfWithTextFragmentToFile threw exception:
System.ArgumentNullException: Value cannot be null. (Parameter ‘key’)
Stacktrace
at System.Collections.Generic.Dictionary2.FindValue(TKey key) at System.Collections.Generic.Dictionary2.TryGetValue(TKey key, TValue& value)
at #=zfZkI5HwMO0AYH2XFAcTHnndrqPOMLOcMgw==.#=zp0wsy5s=(#=z9TkP0rg= #=z9dnZZfI=)
at #=zFwKFlNZeTLXa6$QVg450o7iN40_VO7d3fw==.#=zaG2Tykd$Y0NI`2.#=zEE8Z_GaSDRkR(#=z9TkP0rg= #=z9dnZZfI=, #=zkFyUOhU=& #=z2ux310g=)
at #=zW7MVUlrm5dZ8EWzx1g$HVRTZSgUIbdIAwDDTU1U=.#=zR7NBxxi0Iaqd(#=zpSgslm80$UwTaHu_XI4Tyte7iZ7i #=zFxkNSr7lst6q)
at #=ztGewaiQeCXTE_TAh$tumsx6nToGvtSTO_kI9xgpb4Via.#=zi_6WuoaNpJpK()
at #=ztGewaiQeCXTE_TAh$tumsx6nToGvtSTO_kI9xgpb4Via.#=zEnMhqSk=()
at #=zs71scsxPtkQdVQAvuAmfiZ7YqXpDd03y6$4WQlK2eQr1.#=zYQSpTsY=(#=zDbvJQYhI0CigmE3c4Dr9JXnUYg5_ #=zTrleiB0=, #=z3wcXVPfEaF2Fo7alVowhOFe4XPDhgB68nw== #=zKQHMiyU=, #=zyJecUYaB6pdDfKOoDlWBYnXBNTC4AKpCCXuke8vjl$CM #=zkQunISM=)
at Aspose.Pdf.Page.CalculateContentBBox()
at Aspose.Pdf.Page.#=zhgQeCAs=(Page #=zKQHMiyU=)
at Aspose.Pdf.Page.#=zdlCawL8R2Kntx3CZRQ==()
at Aspose.Pdf.Document.ProcessParagraphs()
at Aspose.Pdf.Document.#=zIgncJc8VsF3C(Stream #=zJywVSn4=, SaveOptions #=zgGb7E$RCz7_R)
at Aspose.Pdf.Document.#=z_Si59eYP6riT(String #=z0jgaUxr5BFT_)
at Aspose.Pdf.Document.Save(String outputFileName)
at XXXX.XXX.XXX.Output.UnitTests.Aspose.PdfDocumentGenerationTests.CanGeneratePdfWithTextFragmentToFile() in /home/jenkins/agent/workspace/common/src/Source/XXX/XXXX.XXX.XXX.Output.UnitTests/Aspose/PdfDocumentGenerationTests.cs:line 33

Attached you can see the failing test.

using System;
using System.IO;

using Aspose.Pdf;
using Aspose.Pdf.Text;

using Microsoft.VisualStudio.TestTools.UnitTesting;

using Shouldly;

namespace XXXX.XXX.XXX.Output.UnitTests.Aspose
{
    [TestClass]
    public class PdfDocumentGenerationTests
    {
        public PdfDocumentGenerationTests()
        {
            FontRepository.Sources.Add(new FolderFontSource(@"/usr/share/fonts/"));
        }

    [TestMethod]
    public void CanGeneratePdfWithTextFragmentToFile()
    {
        const string fileName = "test.pdf";

        try
        {
            using var document = new Document();
            var page = document.Pages.Add();
            var textFragment = new TextFragment("test");
            page.Paragraphs.Add(textFragment);

            document.Save(fileName);

            File.Exists(fileName).ShouldBeTrue();
        }
        finally
        {
            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
        }
    }
    
    [TestMethod]
    public void CanGeneratePdfWithTextFragment()
    {
        using var document = new Document();
        var page = document.Pages.Add();
        var textFragment = new TextFragment("test");
        page.Paragraphs.Add(textFragment);

        using var memoryStream = new MemoryStream();
        document.Save(memoryStream);
        memoryStream.GetBuffer().Length.ShouldBeGreaterThan(0);
    }

    [TestMethod]
    public void CanGeneratePdfWithTextFragmentAndFont()
    {
        using var document = new Document();
        var page = document.Pages.Add();
        var textFragment = new TextFragment("test")
        {
            TextState =
            {
                Font = FontRepository.FindFont("Arial"),
                FontSize = 12
            }
        };
        page.Paragraphs.Add(textFragment);

        using var memoryStream = new MemoryStream();
        document.Save(memoryStream);
        memoryStream.GetBuffer().Length.ShouldBeGreaterThan(0);
    }

    [TestMethod]
    public void CanGeneratePdfWithHtmlFragment()
    {
        using var document = new Document();
        var page = document.Pages.Add();
        var htmlFragment = new HtmlFragment("<h1>Test</h1>");
        page.Paragraphs.Add(htmlFragment);

        using var memoryStream = new MemoryStream();
        document.Save(memoryStream);
        memoryStream.GetBuffer().Length.ShouldBeGreaterThan(0);
    }
}

}

@Tandr

Would you kindly make sure that all Microsoft essential fonts are installed in this directory? Please confirm if msttcorefonts package is installed. In case issue still persists, please let us know.

Yes, I can confirm the Microsoft fonts are installed with ttf-mscorefonts-installer package. The tests are failing regardless of the constructor of the tests - remove it and the tests still fail (only on linux though).

I believe PDF document saving on linux is broken for quite some time and it is surprising to me that nobody noticed.

We have to update to latest version as the one that we currently use has compatibility issues with .NET 6 (particularly issues around FontRepository).

Is there any chance we could get a hotfix version? I guess the whole linux group is affected (incl everyone in containers).

@michalpenka

Are you using Aspose.PDF in a docker container? In that case, can you please provide a sample console application along with sample docker file that we can use to test and replicate the issue?

Yes, I can invest weekend time into doing that if you give me a promise that, should there be a confirmation, you release a hotfix in the next few days.

Otherwise I’d rather (and in fact I need to) invest time into looking into Aspose.Pdf replacement.

We have an enterprise license btw.

Do we have your promise? Are you in a position to make it? If not, who can make it?

@michalpenka

We resolve every issue that is logged in our issue tracking system. However, we also need to replicate it in our environment before we can log it. Furthermore, the resolution or fix time of an issue depends upon number of issues logged prior to it as issues are fixed on first come first serve basis.

We release an update of the API every month and each release contains fixes to the issues reported in previous versions of the API. We are afraid that providing a hotfix is not possible in free support model as it is only provided for the tickets logged under priority/paid support (and only in special cases).

You can kindly share the requested information with us and we assure you that we will investigate and fix the issue as per free support policies.