Gembox failing in alpine linux docker container

Hello,

We’re running into an issue with Gembox only happening when we run our application in alpine docker container. It doesn’t happen in macos, Windows, or Ubuntu. It seems there’s missing dependencies we need to install, but we’re not sure what dependencies we need. This’s our code that throws the exception when we try to convert HTML to PDF using Gembox:

var document = DocumentModel.Load(new MemoryStream(Encoding.UTF8.GetBytes(html)), LoadOptions.HtmlDefault);

document.Save(outputStream, SaveOptions.PdfDefault);

Docker base image we’re using: 8.0-alpine3.19
.net version: 8
Dependencies we’re using:

  • GemBox.Document: 35.0.1852
  • HarfBuzzSharp.NativeAssets.Linux: 7.3.0.2

Anything you could point us to the right direction will be much appreciated. Thank you!

stacktrace:

System.ArgumentNullException: Value cannot be null. (Parameter 'value')\n   at \u000E\u001A\u0019\u0018.\u0008(String \u000F)\n   at \u000E\u001A\u0019\u0018.\u000F(Object \u000F, String \u0008)\n   at \u0003\u000F\u0003\u0019.\u000E(String \u000F)\n   at \u000E\u001B\u000F\u0019..ctor(String \u000F)\n   at \u0003\u001B\u0002\u0019..ctor(\u0008\u0002\u0005\u0018 \u000F, \u0008\u000F\u0015\u0019 \u0008)\n   at \u0005\u001B\u0017\u0019.\u0002\u0016(\u0003\u0002\u0018\u0018 \u000F, \u0005\u0002\u0018\u0018 \u0008)\n   at \u0002\u001B\u0002\u0019.\u0006\u0017(\u000E\u0019\u0003\u0018 \u000F, \u0002\u0002\u0017\u0018 \u0008, \u000E\u0005\u0018\u0018 \u0006)\n   at \u0002\u001B\u0002\u0019.\u000E\u0019(\u000E\u0019\u0003\u0018 \u000F, \u0002\u0002\u0017\u0018 \u0008, \u000E\u0005\u0018\u0018 \u0006, S8 \u0002, X8& \u0003, Boolean \u000E)\n   at \u000E\u0005\u0017\u0019.\u0002\u0005\u001A\u0018\u001B\u0019\u000F\u0017(\u000E\u0019\u0003\u0018 \u000F, \u0002\u0002\u0017\u0018 \u0008)\n   at k.\u0006\u000F\u0018(\u0002\u0005\u001A\u0018 \u000F, \u000E\u0019\u0003\u0018 \u0008, \u0002\u0002\u0017\u0018 \u0006, Double \u0002)\n   at k.\u0008\u000F\u0018(\u0002\u0005\u001A\u0018 \u000F, String \u0008)\n   at k.\u000F\u000F\u0018(\u0002\u0005\u001A\u0018 \u000F, \u0005\u001A\u0019 \u0008)\n   at \u0005\u001A\u0019.\u000E\u0017\u0002\u001B\u0019\u0006(k \u000F, \u0002\u0005\u001A\u0018 \u0008)\n   at k.\u0006\u001B\u0018(\u0002\u0005\u001A\u0018 \u000F, \u0002\u0015\u0019 \u0008)\n   at k.\u0008\u001B\u0018(\u0002\u0005\u001A\u0018 \u000F, \u0002\u0015\u0019 \u0008)\n   at k.\u0003\u0019\u0002\u001B\u0019\u0003\u0019(\u0002\u0005\u001A\u0018 \u000F)\n   at \u0003\u0019\u0002.\u0008\u0017(\u0002\u0005\u001A\u0018 \u000F, \u0008\u0019\u0002 \u0008, \u000F\u000F\u0019 \u0006, \u0006\u000F\u0019 \u0002, \u0005\u000F\u0019 \u0003, \u0005\u000F\u0019 \u000E)\n   at \u000F\u000F\u0019.\u0006\u0002(\u0002\u0005\u001A\u0018 \u000F, \u0008\u0019\u0002[] \u0008, \u0006\u000F\u0019 \u0006, \u0005\u000F\u0019 \u0002, \u0005\u000F\u0019 \u0003)\n   at \u000F\u000F\u0019.\u0003\u0017(\u0002\u0005\u001A\u0018 \u000F, Int32 \u0008, \u0008\u0005\u0019 \u0006, \u0006\u000F\u0019 \u0002, \u000F\u0015\u0002 \u0003, \u0006\u0005\u0019 \u000E)\n   at \u000F\u000F\u0019.\u0006\u0017(\u0002\u0005\u001A\u0018 \u000F, \u0003\u0005\u001A\u0018 \u0008, Int32 \u0006)\n   at \u000F\u000F\u0019.\u000F\u000F\u0019\u001B\u0019\u0006\u0003(Int32 \u000F, Object \u0008, Object \u0006)\n   at GemBox.Document.DocumentModelPaginator.dca75czcds9lmgv2y95q5srjljs9plta\u001B\u0019\u000E\u0016(Int32 \u000F, Object \u0008, Object \u0006)\n   at \u000F\u001A\u0015\u0019.\u0003\u0016\u0016\u0019\u001B\u0019\u000F(\u0005\u0010\u0019 \u000F, String \u0008, Stream \u0006)\n   at \u0002\u0016\u0016\u0019.\u0008\u0016(\u0003\u0016\u0016\u0019 \u000F, \u0005\u0010\u0019 \u0008, Stream \u0006)\n   at GemBox.Document.PdfSaveOptions.\u0002\u0019(\u0005\u0010\u0019 \u000F, Stream \u0008)\n   at GemBox.Document.PdfSaveOptions.67tg5rkvl9zwp8v7723mndgzuc3b4vj8\u001B\u0019\u0005(\u0005\u0010\u0019 \u000F, Stream \u0008, Boolean \u0006)\n   at GemBox.Document.PdfSaveOptions.67tg5rkvl9zwp8v7723mndgzuc3b4vj8\u001B\u0019\u0003(DocumentModel \u000F, Stream \u0008, String \u0006)\n   at GemBox.Document.SaveOptions.67tg5rkvl9zwp8v7723mndgzuc3b4vj8\u001B\u0019\u000E(DocumentModel \u000F, Stream \u0008, String \u0006, Boolean \u0002)\n   at GemBox.Document.DocumentModel.Save(Stream stream, SaveOptions options)\n```
1 Like

Hi Fawaz,

Do you have both HarfBuzzSharp.NativeAssets.Linux and SkiaSharp.NativeAssets.Linux dependencies installed?

If yes, please create a small Visual Studio project that reproduces your issue so we can investigate it.

Regards,
Mario

Hi Mario,

I think my colleague opened a support ticket for the same issue. Yep we do have both HarfBuzzSharp.NativeAssets.Linux and SkiaSharp.NativeAssets.Linux installed. We kinda of fixed the issue by installing these dependencies in our Dockerfile:

RUN apk add --no-cache \
    msttcorefonts-installer \
    fontconfig \
    ttf-dejavu \
    ttf-droid \
    ttf-freefont \
    ttf-liberation \
    icu-libs

That fixed the issue for most documents, but we just run into another document throwing null pointer exception in Gembox. It seems it’s another dependency we might be missing in alpine that Gembox needs.

I was wrong, actually the new issue does not happen only alpine and happens in Windows and macos outside of the container too. So this’s different issue with this document. I think the original issue was resolved by installing the dependencies in the previous post.

I just wanted to add that for “icu-libs” package, some environment variables need to be set.

RUN apk add --no-cache \
    msttcorefonts-installer \
    fontconfig \
    ttf-dejavu \
    ttf-droid \
    ttf-freefont \
    ttf-liberation \
    icu-libs

# Update font cache
RUN update-ms-fonts && fc-cache -f

# Set environment variable for .NET to use ICU
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
ENV LC_ALL=en_US.UTF-8
ENV LANG=en_US.UTF-8
1 Like