Issue Summary
We are using multiple Aspose components in a .NET Core 3.1 application.
The same code works perfectly on Windows 10, but fails on Amazon Linux 2 (EC2) when attempting to load external fonts for Aspose.Slides, Aspose.Imaging, and Aspose.Cells.
The failure happens only after calling:
Aspose.Slides.FontsLoader.LoadExternalFonts(new[] { fontFolder });
Earlier calls to FontRepository.Sources.Add(new FolderFontSource(...)) succeed without issues.
Environment Details
| Item |
Value |
| OS (Working) |
Windows 10 |
| OS (Failing) |
Amazon Linux 2 (EC2) |
| .NET Version |
.NET Core 3.1 |
| Aspose.PDF |
21.6.0 |
| Aspose.Words |
21.6.0 |
| Aspose.Cells |
21.6.0 |
| Aspose.Email |
21.6.0 |
| Aspose.Imaging |
21.6.0 |
| Aspose.Slides.NET |
21.6.0 |
Code Snippet
var fontFolder = Path.Combine(AppContext.BaseDirectory, "ProductionServicev2", "Fonts");
if (Directory.Exists(fontFolder))
{
FontRepository.Sources.Clear();
FontRepository.Sources.Add(new FolderFontSource(fontFolder));
Logger.InfoFormat("Custom font folder added: {0}", fontFolder);
// Works on Windows, fails on Linux
Aspose.Slides.FontsLoader.LoadExternalFonts(new[] { fontFolder });
Console.WriteLine($"Aspose.Slides custom fonts registered from: {fontFolder}");
Aspose.Imaging.FontSettings.SetFontsFolder(fontFolder);
Aspose.Cells.FontConfigs.SetFontFolders(new[] { fontFolder }, true);
}
Exception Trace
System.AggregateException: One or more errors occurred. (The type initializer for ' ' threw an exception.)
---> System.TypeInitializationException: The type initializer for ' ' threw an exception.
---> System.TypeInitializationException: The type initializer for 'Gdip' threw an exception.
---> System.DllNotFoundException: Unable to load shared library 'libgdiplus' or one of its dependencies.
liblibgdiplus: cannot open shared object file: No such file or directory
at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(...)
at System.Drawing.SafeNativeMethods.Gdip..cctor()
--- End of inner exception stack trace ---
at Aspose.Slides.FontsLoader.LoadExternalFonts(String[] fontFolders)
Project Configuration
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Content Include="ProductionServicev2\Fonts\**\*.*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Aspose.PDF" Version="21.6.0" />
<PackageReference Include="SkiaSharp" Version="2.88.6" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.6" />
<PackageReference Include="Magick.NET-Q16-AnyCPU" Version="13.1.3" />
<PackageReference Include="PdfiumViewer" Version="2.13.0" />
<PackageReference Include="AWSSDK.Textract" Version="3.7.501.4" />
</ItemGroup>
</Project>
The Fonts folder is copied to the output directory and accessible at runtime.
What I Need Help With
- Does
Aspose.Slides.FontsLoader.LoadExternalFonts() depend on System.Drawing / libgdiplus on Linux platforms?
- What are the required dependencies or setup steps to make this work correctly on Amazon Linux 2 with .NET Core 3.1?
- Is there a recommended alternative for font loading in Linux (for example, using SkiaSharp or a built-in Aspose renderer)?
- Are specific font formats (TTF / OTF) or permissions known to trigger this issue?
Expected Behavior
The external fonts should load from the provided folder on Linux just as they do on Windows, without dependency errors.
@ragu2736
Summary
Aspose.Slides.FontsLoader.LoadExternalFonts in Aspose.Slides 21.6.0 uses the legacy System.Drawing implementation on Linux. System.Drawing requires the native library libgdiplus. Because Amazon Linux 2 (and many minimal containers) do not include this library by default, the call throws a DllNotFoundException.
Why it happens
| Reason |
Details |
| System.Drawing dependency |
In the 21.x line of Aspose.Slides the font loader calls GDI+ (via System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup). On Linux GDI+ is supplied by the native libgdiplus library. |
| Missing native package |
Amazon Linux 2 does not ship libgdiplus out of the box, so the runtime cannot locate it and raises DllNotFoundException. |
| File‑system permissions |
Even with libgdiplus present, the process must be able to read the font files you point to. |
| Version limitation |
From Aspose.Slides 22.10 onward the rendering engine was switched to SkiaSharp, which no longer depends on System.Drawing or libgdiplus. The older 21.6.0 build therefore cannot avoid the native dependency. |
What to do next
- Install the required native libraries on the EC2 instance (or Docker image)
# Update package index
sudo yum update -y
# Enable EPEL repository (provides libgdiplus)
sudo amazon-linux-extras install epel -y
# Install libgdiplus (provides GDI+ for System.Drawing)
sudo yum install -y libgdiplus
# Install fontconfig (helps the system locate fonts)
sudo yum install -y fontconfig
# Verify the library is visible to the loader
ldconfig -p | grep libgdiplus
Add the same commands to your Dockerfile if you run the app inside a container.
- Make sure the custom‑font folder is readable by the application
chmod -R a+r /path/to/ProductionServicev2/Fonts
# or, restrict to the specific app user
chown -R <app_user>:<app_group> /path/to/ProductionServicev2/Fonts
- (Recommended) Upgrade Aspose components to a Skia‑based version
- Update the NuGet packages to 22.10 or newer (use the same major version for Slides, Cells, Imaging, etc.).
- The newer packages bring the required Skia binaries automatically, so you do not need to add
SkiaSharp or SkiaSharp.NativeAssets.Linux.NoDependencies manually.
- After the upgrade the same code works without
libgdiplus:
var fontFolder = Path.Combine(AppContext.BaseDirectory, "ProductionServicev2", "Fonts");
FontRepository.Sources.Clear();
FontRepository.Sources.Add(new FolderFontSource(fontFolder));
// In 22.x the call no longer touches System.Drawing
Aspose.Slides.FontsLoader.LoadExternalFonts(new[] { fontFolder });
Aspose.Imaging.FontSettings.SetFontsFolder(fontFolder);
Aspose.Cells.FontConfigs.SetFontFolders(new[] { fontFolder }, true);
- Alternative if you cannot upgrade
- Use only
FolderFontSource (as you already do) and omit the explicit call to FontsLoader.LoadExternalFonts.
- For most rendering scenarios Aspose.Slides will pick up the fonts from the repository automatically.
- Be aware that some advanced text‑layout features may still invoke System.Drawing internally; the upgrade remains the safest long‑term fix.
- Validate the change
- Run the application again on the Linux instance. The
DllNotFoundException should no longer appear and the presentation should render with the custom fonts.
- If the error persists, confirm that
libgdiplus resides in a directory listed in LD_LIBRARY_PATH or /etc/ld.so.conf.d/, then re‑run ldconfig.
Next steps
- Choose either the immediate workaround (install
libgdiplus and adjust permissions) or the longer‑term upgrade to Aspose 22.10+.
- Apply the corresponding changes, redeploy, and verify that the presentation renders correctly.
Note: The above guidance is based on known behavior of Aspose.Slides 21.x and Linux GDI+ requirements. The specific RAG evidence retrieved does not contain direct citations for these details, so please verify the steps in your environment.
If you encounter further issues after applying these steps, let me know which path you took so I can help fine‑tune the configuration.
I could not fully verify this explanation against the retrieved sources. Please double-check the behaviour in your environment and confirm the exact SDK/version.
@ragu2736,
Please note, regarding Aspose.Cells, since you are using .NET Core 3.1 along with an older version of Aspose.Cells (21.6.0), please note that at that time, the component relied on System.Drawing.Common instead of SkiaSharp. This may result in limited support on non-Windows operating systems.
Moreover, please do consider installing packages such as: libgdiplus for rendering graphics, fontconfig - install (or include) Microsoft-core fonts (if you rely on Windows fonts like Arial, Times New Roman, etc.). Furthermore, for fonts, if your spreadsheets use fonts not present on Linux, you must ensure those fonts are installed or embedded otherwise layout/rendering may behave differently, or conversion may fail. See the document for reference: Configuring Fonts for Rendering Spreadsheets|Documentation
Starting from Aspose.Cells version 22.10.1 for .NET 6+ platforms, SkiaSharp was introduced to enhance compatibility for non-Windows environments . To ensure optimal functionality and long-term compatibility, we recommend upgrading to .NET 6 (or later) and updating Aspose.Cells to a newer version (e.g., v25.11(latest version)) that fully supports SkiaSharp on Linux.
Regarding Aspose.Slides and Aspose.Imaging APIs, my colleagues from Aspose.Slides and Aspose.Imaging teams will response you soon here.
Aspose.Imaging works under Linux with libgdi plus (described in docs Working with Aspose.Imaging .NET Core DLLs in non Windows environment|Documentation) and can work without libgdi plus (starting from net7.0+). Also exist special package Aspose.Imaging.Drawing NuGet Gallery | Aspose.Imaging.Drawing 25.10.0 which includes special versions of Aspose.Imaging for NetStandard2.0,NetCore3.1,Net6.0 that does not require install of libgdi plus and uses own graphics engine.
@ragu2736,
Please note the following.
Currently, there are two main builds of Aspose.Slides for .NET:
This is the main version of the product. It uses the standard .NET graphics engine.
- On non-Windows platforms, you may need to install the
libgdiplus library and its dependencies.
- Prior to version Aspose.Slides 25.3, for non-Windows platforms, it was necessary to use the .NET Standard 2.0 DLL from the Aspose.Slides ZIP package.
- Starting from version Aspose.Slides 25.3, the NuGet package can be used directly even on non-Windows systems.
- When running on non-Windows systems, your application must include the following line at startup:
AppContext.SetSwitch("System.Drawing.EnableUnixSupport", true);
- Starting from version 25.3, you can use this package on platforms that support .NET, such as Linux aarch64 (ARM64).
This is the version of Aspose.Slides using a proprietary cross-platform graphics engine developed by the Aspose.Slides team.
On non-Windows platforms, the fontconfig library may be required.
Supported Platforms
- Windows: x86, x86_64
- Linux: x86_64
- macOS: x86_64, ARM64
Planned for Future Support
- Linux: aarch64 (ARM64) — ETA: end of 2025
Not Planned
- Windows 11 ARM (ARM64) — Not currently under consideration
We hope this information is sufficient.
System Requirements|Aspose.Slides Documentation