We're sorry GroupDocs doesn't work properply without JavaScript enabled.

Free Support Forum - groupdocs.com

Error converting docx to png in .Net 6 on Linux in versions 22.1 and 22.2

Hello, I have recently upgraded my .Net project from Core 3.1 to .Net 6, and my GroupDocs.Conversion version from 20.9.3 to 22.2. I also switched my OS from Windows to Linux, which meant I had to start including libgdiplus in my install

Both 22.1 and 22.2 are working fine in all scenarios but one: Converting DOCX to PNG throws an error:

Unhandled Exception: GroupDocs.Conversion.Exceptions.GroupDocsConversionException: The type initializer for ’ threw an exception.
at #002#005#003.#002()
at GroupDocs.Conversion.Converter.#002()
at GroupDocs.Conversion.Converter.Convert(SaveDocumentStream document, ConvertedDocumentStream documentCompleted, ConvertOptions convertOptions)

Converting from DOCX to PDF works fine - the error is only for pngs.

I believe this is the same issue this post except for PNGs instead of PDFs:

This makes sense as the PDF issue was apparently fixed in version 21.11 under the following id:


What other information do you need?

1 Like

Just to be clear all other document types are converting to PNG, including Excel and PowerPoint. The only one having the issue is DOCX


Please share following details and we’ll investigate this issue:

  • DOCX to PNG conversion code
  • Development environment details (e.g. OS name/version)
  • Source/problematic file(s)

Make sure you configured/installed libgdiplus like this:

apt-get update
apt-get install -y libgdiplus
apt-get install -y ttf-mscorefonts-installer fontconfig
  • DOCX to PNG conversion code:

      public override async Task<Stream> ConvertToThumbnailAsync(Stream source, int width, int height)
          Stream thumbnailStream = null;
          using (Converter converter = new Converter(() => source))
              thumbnailStream = new MemoryStream();
              var options = new ImageConvertOptions
                  Format = ImageFileType.Png,
                  PageNumber = 1,
                  PagesCount = 1,
                  Height = height
              converter.Convert(() => new MemoryStream(), (convertedStream, x) =>
              }, options);
          return await Task.FromResult(thumbnailStream);
  • Development environment details

Amazon Linux 2 version 2.2.11

  • Source/problematic file(s)

I don’t think this error has anything to do with the specific file, but here are a few that fail:

qbf.docx (11.7 KB)
Welcome to Word.docx (1.3 MB)

  • Make sure you configured/installed libgdiplus like this

This is not Ubuntu. There is no apt-get and there is no yum package called ttf-mscorefonts-installer. What’s the alternative for Amazon Linux? (which I think is redhat. I don’t usually work with Linux)

1 Like


This issue is logged in our internal issue tracking system with ticket ID CONVERSIONNET-5146. You’ll be notified in case of any progress update.