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

Free Support Forum - aspose.com

Docker .Net Core: Converting HTML to PDF

It crashes on the constructor of the Document class. Ver 18.2 works in Windows but fails when running inside Docker Linux.


Kindly share all details of the scenario, including source PDF, development platform and code. Your response is awaited.

I can’t provide you the source html but I don’t think it will matter. I have provided below the source code:

private static string ConvertFromHtml(string html)
byte[] buffer = Encoding.UTF8.GetBytes(html);
string base64String;

    using (var inputStream = new MemoryStream(buffer))
        using (var document = new Aspose.Pdf.Document(inputStream, new HtmlLoadOptions { InputEncoding = "UTF-8" }))
            using (var outputStream = new MemoryStream())
                document.Save(outputStream, SaveFormat.Pdf);
                outputStream.Seek(0, SeekOrigin.Begin);

                byte[] temp = outputStream.ToArray();
                base64String = System.Convert.ToBase64String(temp);

    return base64String;

The exception is thrown by the constructor Aspose.Pdf.Document. The error is:

System.TypeInitializationException: The type initializer for ‘Gdip’ threw an exception. —> System.DllNotFoundException: Unable to load DLL ‘libdl’


  • .Net Core 2.0 Runtime
  • Docker Linux
  • Aspose.PDF Version 18.2

The same above code runs in Windows but fails if inside Docker.


We have logged an investigation under the ticket ID PDFNET-44286 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.


The linked ticket ID PDFNET-44286 has been resolved. Please download and try the latest version 18.6 of Aspose.PDF for Java API. You need to consider some additional changes in your environments, in order to apply complete solution to the problem. You should please install:

  1. libgdiplus package
  2. package with Microsoft compatible fonts: ttf-mscorefonts-installer. (e.g.: sudo apt-get install ttf-mscorefonts-installer)

These fonts should be placed in “/usr/share/fonts/truetype/msttcorefonts” folder (our API scan this folder on Linux like systems). If OS has other default folder for fonts, you should add following command at the beginning of your code:

Aspose.Pdf.Text.FontRepository.Sources.Add(new FolderFontSource("<user's path to ms fonts>"))

In case of any further assistance, please feel free to let us know.