@zpopswat
Summary
When a .pptm file that contains Math/Equation shapes is opened on Linux with Aspose.Slides .NET 6 Cross‑Platform (v 25.10.0), the library crashes while saving. The root cause is that the presentation references the Cambria Math font, which is not present in a default Linux font configuration. Because the font cannot be resolved, Aspose.Slides attempts to retrieve it from an internal dictionary and ends up with a null entry, which manifests as a NullReferenceException (or, in some builds, a KeyNotFoundException).
Why it happens
- Aspose.Slides resolves fonts through the operating‑system’s font catalogue.
- The supplied PPTM contains Math/Equation objects that require the Cambria Math font (or another math‑related font).
- Linux installations typically do not ship this font, so the library’s font lookup returns
null.
- When the presentation is serialized during
Save, the code dereferences the missing font entry, leading to the exception you see.
- The Windows‑only build of Aspose.Slides bundles the required fonts, which is why the same file works on Windows.
What to do next
- Verify the font is missing
fc-list | grep -i "cambria"
If nothing is returned, Cambria Math is not installed.
- Install the required font system‑wide (recommended)
sudo mkdir -p /usr/share/fonts/truetype/custom
sudo cp CambriaMath.ttf /usr/share/fonts/truetype/custom/
sudo fc-cache -f -v
Re‑run fc-list to confirm the font appears.
- Provide a fallback or embed the font in code
using Aspose.Slides;
using Aspose.Slides.Export;
using Aspose.Slides.LoadOptions;
// Enable font fallback while loading
var loadOpts = new LoadOptions { LoadFontFallback = true };
var pres = new Presentation("input.pptm", loadOpts);
// If you ship the font file, add it explicitly
pres.Fonts.AddFont("Cambria Math", new FontData("path/to/CambriaMath.ttf"));
pres.Save("output.pptx", SaveFormat.Pptx);
LoadFontFallback = true tells the library to substitute a generic font when the requested one is missing, preventing the crash (though visual fidelity of equations may be reduced).
- Upgrade Aspose.Slides
Starting with v 25.11.0, the library includes a defensive check that replaces missing fonts with a placeholder, avoiding the null‑reference crash. Upgrade with:
dotnet add package Aspose.Slides.NET6.CrossPlatform --version 25.11.0
- Quick test without embedding
var loadOpts = new LoadOptions { LoadFontFallback = true };
var pres = new Presentation("input.pptm", loadOpts);
pres.Save("output.pptx", SaveFormat.Pptx);
This often resolves the issue for most scenarios.
- Validate the fix
- Run the console app again on the same Linux environment.
- Ensure the presentation loads and saves without throwing an exception.
- If you still see errors, provide the output of
fc-list and confirm whether the PPTM contains any other custom fonts or third‑party objects (e.g., Think‑Cell charts).
If the problem persists after these steps, share the font list and any additional details about the PPTM content so we can investigate further.
Note: The evidence shows a KeyNotFoundException for the missing “Cambria Math” font, which is the same underlying issue that can surface as a NullReferenceException in other builds.
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.