Running Aspose.Slides for .NET in an Alpine Container Throws an Exception

So we are running aspose slides net in an alpine container and facing the error below when the presentation is saved to a memory stream.

System.ArgumentException: Font '?' cannot be found.
   at System.Drawing.SafeNativeMethods.Gdip.CheckStatus(Int32 status)
   at System.Drawing.FontFamily.GetCellAscent(FontStyle style)
   atont )
   attring ,oolean , Int32 , & )
   at␦ ,nt32 , Boolean ,  , &)
   at oolean&)
   at .()
   at ..ctor(TextFrame ,␦, IBaseSlide ,␦[] )
   at␦ , ␦)
   at ingle, Single , ␦ )
   at ␦&, RectangleF& , ␦ )
   at hapeFrame&, RectangleF& , ␦ )
   at
t .(IAutoShape , ,  ,  )
   at .(IShape , ,  ,  )
   at .(IGroupShape , ,  ,  )
   at .(IBaseSlide , ,  )
   at .(ILayoutSlide , ,  )
   at .(ILayoutSlide )
   at ␦ , ILayoutSlide, ␦␦ ,
t ␦ , IMasterSlide, Boolean ,
t resentation , , IPptxOptions , InterruptionToken )
   at resentation , Stream,  , IPptxOptions , InterruptionToken )
   at Aspose.Slides.Presentation.(Stream , , IPptxOptions )
   at Aspose.Slides.Presentation.Save(Stream stream, SaveFormat format, ISaveOptions options)
   at Aspose.Slides.Presentation.Save(Stream stream, SaveFormat format)
   at Program.<Main>$(String[] args) in /app/Program.cs:line 26

We are using Aspose.Slides.NET Version=25.5.0.

I want to know if this issue can be resolved without changing the runtime alpine image or using Aspose.Slides.CrossPlatform we already tried it and had other issues come up unrelated to aspose slides. So neither of those are good options for us.

I am uploading the proof of concept app which can reproduce the error when you build and run the docker file.

SlidesTest.zip (405.2 KB)

@Raiden238

It looks like you’re encountering a System.ArgumentException related to a missing font when using Aspose.Slides in an Alpine container. This issue typically arises because the Alpine image lacks the necessary font libraries that Aspose.Slides relies on for rendering.

Cause: The error is due to missing font libraries in the Alpine container, which are essential for Aspose.Slides to function correctly.

Solution: Here are the steps you can take to resolve this issue without changing your runtime Alpine image or switching to Aspose.Slides.CrossPlatform:

  1. Install Font Packages: Ensure that you have the required font packages installed in your Alpine container. You can add the following lines to your Dockerfile to install common font packages:

    RUN apk add --no-cache fontconfig ttf-dejavu
    
  2. Configure Font Directory: After installing the fonts, configure the font directory by setting the FONTCONFIG_PATH environment variable in your Dockerfile:

    ENV FONTCONFIG_PATH=/etc/fonts
    
  3. Test with a Simple Presentation: Create a simple presentation that uses standard fonts (like Arial or Times New Roman) to see if the issue persists. This can help isolate whether the problem is with specific fonts.

  4. Check Font Availability: Verify the available fonts in your container by running:

    fc-list
    

    This command will list all the fonts that are currently available.

  5. Fallback Fonts: If your presentation uses custom fonts, consider embedding those fonts directly into the presentation or using fallback fonts that are available in the Alpine environment.

Next Steps: Implement the above changes in your Dockerfile and rebuild your container. After that, test your application again to see if the issue is resolved.

By following these steps, you should be able to resolve the font-related issue without needing to change your base image or use a different version of Aspose.Slides.

If you have any further questions or need additional assistance, feel free to ask!

@Raiden238,
Thank you for contacting free support. I need some time to check the issue. I will get back to you as soon as possible.

@Raiden238,
Thank you for your patience. I have reproduced the exception you described. We apologize for any inconvenience caused.

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

Issue ID(s): SLIDESNET-45068

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.