Failed to Create PDF with special fonts

Hi,

We experience some issues with special fonts when producing PDF in C# using Aspose - System.NullReferenceException

Font: code128.ttf
Aspose.Words version: 19.01
OS: Linux (but it does not work on Windows either)
DotNet Core 6.0

Code sample:

public void Sample(byte[] htmlData)
{
    // Load external fonts
    var fontPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ExtraFonts");
    var fontSources = new System.Collections.ArrayList(Aspose.Words.Fonts.FontSettings.DefaultInstance.GetFontsSources());
    var folderFontSource = new Aspose.Words.Fonts.FolderFontSource(fontPath, true);
    fontSources.Add(folderFontSource);
    var updatedFontSources = (Aspose.Words.Fonts.FontSourceBase[])fontSources.ToArray(typeof(Aspose.Words.Fonts.FontSourceBase));
    Aspose.Words.Fonts.FontSettings.DefaultInstance.SetFontsSources(updatedFontSources);

    // Generate document
    var doc = new Aspose.Words.Document();
    var builder = new Aspose.Words.DocumentBuilder(doc);
    using (var sr = new StreamReader(new MemoryStream(htmlData)))
        builder.InsertHtml(sr.ReadToEnd(), false);
    using (var target = new MemoryStream())
    {
        doc.Save(target, Aspose.Words.SaveFormat.Pdf); // Fails here...
    }
}

Exception:

System.NullReferenceException: 'Object reference not set to an instance of an object.'

Stack trace:

at Aspose.Words.Document.(    , SaveOptions )
at Aspose.Words.Document.(Stream , String , SaveOptions )
at Aspose.Words.Document.Save(Stream stream, SaveOptions saveOptions)
at Aspose.Words.Document.Save(Stream stream, SaveFormat saveFormat)

It seems to work in version 19.02, but we’re unable to upgrade right now.
Do you have any suggested workaround to work with 19.01?

@ODBCI Could you please attach the problematic document and font here for testing? Unfortunately, it is difficult to say what causes the exception without documents and fonts.
If you are sure, the problem is caused by code128.ttf font, as a temporary workaround, you can avoid using the font. But as a solution of the problem, I would suggest you to update to the latest version of Aspose.Words.