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

Free Support Forum - aspose.com

Converter.ConvertMHTML throws System.PlatformNotSupportedException: System.Drawing.Common is not supported on this platform in Linux container

Here is the stacktrace:

anzen_server       |       IndexWorker: Unexpected exception while indexing Document with Id '0046b904-9a1f-47bb-b2df-2098dc51c5fa': System.PlatformNotSupportedException: System.Drawing.Common is not supported on this platform.
anzen_server       |          at System.Drawing.Drawing2D.Matrix..ctor(Single m11, Single m12, Single m21, Single m22, Single dx, Single dy)
anzen_server       |          at Aspose.Html.Rendering.Pdf.PdfDevice.BeginPage(SizeF size)
anzen_server       |          at ♥   .☻      ☻(IDevice ☻)
anzen_server       |          at ♣   .☼​     ☻(Renderer ☻, ♣   [] ♥, IDevice ♣, TimeSpan)
anzen_server       |          at Aspose.Html.Rendering.MhtmlRenderer.☻(IDevice ☻, Configuration ♥, TimeSpan ♣, Stream[])
anzen_server       |          at Aspose.Html.Rendering.MhtmlRenderer.Render(IDevice device, Stream document, Configuration configuration, TimeSpan timeout)
anzen_server       |          at Aspose.Html.Rendering.MhtmlRenderer.Render(IDevice device, Stream document, Configuration configuration)
anzen_server       |          at ♠  .☻(♥   ☻, IDevice ♥)
anzen_server       |          at ♠  .♥     ☻(♥   ☻, PdfSaveOptions ♥, ICreateStreamProvider ♣)
anzen_server       |          at ♠  .♥     ☻(♥   ☻, PdfSaveOptions ♥, String ♣)
anzen_server       |          at Aspose.Html.Converters.Converter.ConvertMHTML(Stream stream, PdfSaveOptions options, String outputPath)

Is there a special version for Linux? I’ve already special versions for Aspose.PDF and Aspose.Imaging :wink:


Would you kindly share a bit more details like sample input document, code snippet, and docker file? We will log an investigation ticket and rectify this issue.

This happens with every mhtml I convert to an PDF.
The Mhtml is created by Apose.HTML itsself from an *.eml or *.msg-File.
I’m using .NET 7 for this.

I will try if I can put together an example for you.


Please take your time to put together an example and share it with us. We will log an issue in our issue tracking system and share the ID with you.

I have build a little example complete with Dockerfile and docker compose. Just extract it and execute
“docker-compose up” which will build the VS solution and executes the container.

It will run on Windows without problems, but will give the exception “The type initializer for ‘Gdip’ threw an exception.” on Linux, which is a new exception to me.

20230124_Mhtml_Linux_Fails.zip (180.1 KB)


We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): HTMLNET-4250

You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.

1 Like


The current version does not support Net 7 on Linux. But we are preparing to add Net 7 support on Linux and a new Drawing system in Q2 2023.

That’s nice but it fails also on .NET 6.
I’ve attached you the same example as a .NET 6 solution and docker container.

20230124_Mhtml_Linux_Fails NET6.zip (19.8 KB)


Try to set a specific folder for fonts and put the necessary fonts there:

public void Test()
    string[] fontsFolders = { "/fontFolder/" };

    var configuration = new Configuration();
    var userAgentService = configuration.GetService<IUserAgentService>();
    userAgentService.FontsSettings.SetFontsLookupFolders(fontsFolders, true);

You can also process the selection of fonts and substitute a specific font:

    configuration.GetService<IUserAgentService>().FontsSettings.FontMatcher = new ArialFontMatcher();

    using (HTMLDocument doc = new HTMLDocument(source, "", configuration))
private class ArialFontMatcher : FontMatcher
     private readonly byte[] font;

     public ArialFontMatcher()
          font = File.ReadAllBytes(fontsFolders[0] + "arial.ttf");

     public override byte[] MatchFontFallback(FontMatchingProperties fontMatchingProperties, uint charCode)
          return font;

Please have a look at my solution: I do not want to open the HTML, I want to convert it to PDF with
Aspose.Html.Converters.Converter.ConvertMHTML(htmlStream, pdfSaveOptions, tempFileNamePdf);
which has no option for a font folder.

Also an exception is occuring within the Converter.ConvertMHTML() call which has nothing to do with fonts.

The exception is:
aspose_mhtml | Unhandled exception. System.TypeInitializationException: The type initializer for ‘Gdip’ threw an exception.
aspose_mhtml | —> System.DllNotFoundException: Unable to load shared library ‘libdl’ or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibdl: cannot open shared object file: No such file or directory


We have updated the ticket information accordingly and will let you know once we make some further updates regarding its resolution.