Unable to Save PPTX in the Output Directory when Deployed on Linux Server

I am getting this error

System.ArgumentException: No codec available for format:b96b3cae-0728-11d3-9d7b-0000f81ef32e
at System.Drawing.Image.Save(Stream stream, ImageFormat format)
atPresentation )
atresentation , Stream , PresentationTypeEx , IPptxOptions, InterruptionToken )
at Aspose.Slides.Presentation.(Stream , PresentationTypeEx , IPptxOptions )
at Aspose.Slides.Presentation.Save(Stream stream, SaveFormat format, ISaveOptions options)
at Aspose.Slides.Presentation.Save(String fname, SaveFormat format)
at IRA.Core.Services.IraReportService.GetIraPPTX(IraData data) in D:\Projects\stt-internal-reporting-automation\code\internal-reporting-automation\api-dot-net\IRA.Core.Services\IraReportService.cs:line 119

when i try to deploy my .NET application in the dotnet server. I am using .NET version 5 and Aspose.Slides.NET" Version=“22.11.0” .
This is the code file where i am generating the ppt.

private Presentation pptx = new Presentation();
private static Random random = new Random();

public static string RandomString(int length)
{
    const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    return new string(Enumerable.Repeat(chars, length)
        .Select(s => s[random.Next(s.Length)]).ToArray());
}

public string GetIraPPTX(IraData data)
{
    try
    {

        License license = new License();
        license.SetLicense("Aspose.Slidesfor.NET.lic");

        bool isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
        string outputDirectory;

        if (isLinux)
        {
            outputDirectory = @"/home/micro/storage/TempPPTX/" + RandomString(10) + ".pptx";
        }
        else
        {
            // outputDirectory = @"D:\Desktop\projects\generatedPPTs\" + RandomString(10) + ".pptx";
            outputDirectory = @"C:\Users\MohammadKaifKhan\Desktop\Projects\generatedPPTx\" + RandomString(10) + ".pdf";
        }

        pptx.Slides[0].Remove();
        // First two slides
        DatacenterSlide cs = new DatacenterSlide();
        Presentation csPPTX = cs.getSlide(presTemplate, data);
        MergePPTX(csPPTX);
        pptx.Save(outputDirectory, SaveFormat.Pptx);
    }
}

protected void MergePPTX(Presentation child)
{
    foreach (ISlide slide in child.Slides)
    {
        pptx.Slides.AddClone(slide);
    }
}

(Ignore the syntax errors)

@izzmekaif

The error you are encountering, System.ArgumentException: No codec available for format:b96b3cae-0728-11d3-9d7b-0000f81ef32e, typically arises when there is an issue with the image codecs on the Linux server. This is a known issue when using Aspose.Slides on Linux, particularly with certain formats that rely on the System.Drawing.Common library, which may not be fully supported in Linux environments.

To resolve this issue, consider the following steps:

  1. Update Aspose.Slides: Ensure you are using the latest version of Aspose.Slides for .NET. The issue you are facing has been addressed in version 22.8 and later. You can download the latest version from the Aspose website.

  2. Install Required Libraries: Make sure that the necessary libraries are installed on your Linux server. Specifically, you need to install libfontconfig1 and libfreetype6. These libraries are essential for rendering fonts and images correctly.

  3. Use Alternative Libraries: If you continue to face issues, consider using alternative libraries or methods for handling images in your presentations. This may involve using different image formats or libraries that are better supported on Linux.

  4. Check Permissions: Ensure that the application has the necessary permissions to write to the output directory specified in your code. Sometimes, permission issues can also lead to errors when saving files.

Here is a brief code snippet to check if the output directory is writable:

if (!Directory.Exists(outputDirectory))
{
    Directory.CreateDirectory(outputDirectory);
}

By following these steps, you should be able to resolve the issue and successfully save your PPTX files on the Linux server. If the problem persists, consider reaching out to Aspose support for further assistance.

Sources:
[1]: Specific PPTX Causes OutOfMemoryException when Saving It in C# on Linux