We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

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


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;


    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


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


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


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 (https://docs.aspose.com/pdf/net/docker/)

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


In the csproj you must specify this new item group

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

And It’s works


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.