Aspose Pdf copy memory stream in docker container generate erreur not null reference

Hello,

I try to load a pdf in memory stream and copy to an other memory stream. In mac and windows os execution it’s works but in docker I have an exception :
System.NullReferenceException: Object reference not set to an instance of an object.

byte[] buff = File.ReadAllBytes(“file.pdf”);
using (var memoryStream = new MemoryStream(buff))

{

    memoryStream.Position = 0;

    //PDF

    Aspose.Pdf.Document srcDocument = new(memoryStream);

    Aspose.Pdf.Document dstDocument = new();

    //save document pdf

    using (MemoryStream outStream = new())

    {

        dstDocument.Save(outStream, SaveFormat.Pdf);

    }

}

I’send you my project in attachement with the docker file

Thanks,
Regards,
Nicolas

The project link => https://we.tl/t-BjPRUTYbCg

@NNO

We have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as PDFNET-51661. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

How soon can we expect to have a fix ? Thanks

@NNO

Currently, your issue is pending for analysis and is in the queue. Once we complete the analysis of your issue, we will then be able to provide you an estimate.

Hello, I found the problem:

  1. In the dockerfile

The base image must be create with this package (How to run Aspose.PDF in Docker|Aspose.PDF for .NET)

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base

RUN apt-get update && apt-get install -y libgdiplus

RUN sed -i'.bak' 's/$/ contrib/' /etc/apt/sources.list

RUN apt-get update; apt-get install -y ttf-mscorefonts-installer fontconfig

Breaking change .net core 6

[Breaking change: System.Drawing.Common only supported on Windows - .NET | Microsoft Learn]

In the csproj you must specify this new item group

 <ItemGroup>
        <RuntimeHostConfigurationOption Include="System.Drawing.EnableUnixSupport" Value="true" />
   </ItemGroup>

And It’s works

@NNO

It is nice to hear from you that you have resolved your issue. Please let us know if you have any more queries related to Aspose.PDF.