Error using CustomFont directory when converting docx to pdf on linux server

We use the following code snippet to convert from docx to pdf using GroupDocs.Conversion for .Net ver 22.5.0:

private static LoadOptions LoadOptionsForWordDoc => new WordProcessingLoadOptions {EmbedTrueTypeFonts=true};
        private static ConverterSettings ConverterSettings => new ConverterSettings(){ FontDirectories = new List<string>(){ Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "CustomFonts/")}};
        public async Task<byte[]> ConvertToPdf(string filename, byte[] docxFile, bool applyCommsFormatting = true)
        {
            try
            {
                var pdfConvertOptions = new PdfConvertOptions();

                var converter = applyCommsFormatting ?
                                new Converter(() => new MemoryStream(docxFile), () => LoadOptionsForWordDoc, () => ConverterSettings) :
                                new Converter(() => new MemoryStream(docxFile), () => ConverterSettings);
                                   
                var pdfStream = new MemoryStream();
                converter.Convert(() => pdfStream, pdfConvertOptions);

                return pdfStream.ToArray();
            }
            catch (Exception ex)
            {
                _logger.Error(ex.ToString());
            }
            return null;
        }

The code works well on my local windows machine but on our linux server throws the following error:

GroupDocs.Conversion.Exceptions.GroupDocsConversionException: The type initializer for ‘  ’ threw an exception.
at d.()
at GroupDocs.Conversion.Converter.()
at Core.Services.DocumentService.ConvertToPdf(String filename, Byte[] docxFile, Boolean applyCommsFormatting)

I checked the file path to custom fonts and can see the font folder in server. Could you please check and let us know what is causing the exception?

@lekha.menon

Please share following details and we’ll look into this issue:

  • A short video explaining the steps to reproduce the issue on your server
  • Problematic DOCX file
  • Server details (name, version etc)

Docx file:
3737_W062_Advise Rehab is Exhausted_11-3665.docx (39.5 KB)

Pdf file generated using the using GroupDocs.Conversion for .Net ver 22.5.0:
3737_W062_Advise Rehab is Exhausted_11-3665.pdf (49.0 KB)

On click of download button, the program reads the docx file from an FTP site and passes the byte array to the above program.

The server name and version: Red Hat Enterprise Linux release 8.5 (Ootpa)

@lekha.menon

We are investigating this scenario. Your investigation ticket ID is CONVERSIONNET-5313. We’ll notify you as there’s any progress update.

@lekha.menon

There is an update on CONVERSIONNET-5313. The exception is thrown because of missing libraries on your Linux system.
The needed libraries are:
libgdiplus
ttf-mscorefonts-installer
fontconfig

Installation in Ubuntu is pretty straightforward:

sudo apt-get install -y libgdiplus
sudo apt-get install -y ttf-mscorefonts-installer fontconfig

For redhat, you could try the following (of the best known commands to install these libraries):

yum whatprovides libgdiplus

and that install the library which was listed from the above command e.g.:

yum install -i libgdiplus-2.10-10.el7.x86_64

The issues you have found earlier (filed as CONVERSIONNET-5313) have been fixed in this update. This message was posted using Bugs notification tool by nikola.yankov