Aspose.PDF Aspose.Pdf.Document.Save - System.NullReferenceException

We’re getting a “System.NullReferenceException: Object reference not set to an instance of an object.” when Document.Save() gets called.

Here is the function:
image.png (43.7 KB)

private static Stream EmptyPdfProperties(Stream stream)
        {
            using (stream)
            using (var document = new Document(stream))
            {
                document.Info.Clear();
                document.Info.ClearCustomData();
                document.Info.Creator = null;
                document.Info.Producer = null;
                document.RemoveMetadata();
                var saveStream = new MemoryStream();
                document.Save(saveStream);
                return saveStream;
            }
        }

And here is the error:

Error Message:
   System.NullReferenceException : Object reference not set to an instance of an object.
  Stack Trace:
     at #=z3JXk2lE25oawxr0FM$ZQrw0lhMKz.#=z8Xmu998=(#=zFmA20cmyVm5QZ$0jFMrqaP3Ohjh1 #=zApgLdk7MrIle)
   at #=zC6nyPlKFSUNCAHcjJkI7tco=.#=zoYQrNls=(#=zFmA20cmyVm5QZ$0jFMrqaP3Ohjh1 #=zApgLdk7MrIle)
   at #=q1qifqgbfO3$0lc0sUiNkrfD41PlaQOxJx055JuE8yN4=.#=z8Z9l9_sJ62wjsQAg0pnkD3gdbc2HPkyPT6YWJc0=(Object #=zNNPnWh0=)
   at #=q1qifqgbfO3$0lc0sUiNkrfD41PlaQOxJx055JuE8yN4=.#=zFan8Rl5VK_ecWt2bpDUYlXUJlE87vDlIvWOWkEg=(MethodBase #=zNNPnWh0=, Boolean #=zDhtUuHA=)
   at #=q1qifqgbfO3$0lc0sUiNkrfD41PlaQOxJx055JuE8yN4=.#=zNYQTQOkWntJjsENt3BT0_cI=(#=q1qifqgbfO3$0lc0sUiNkrfD41PlaQOxJx055JuE8yN4= #=zNNPnWh0=, #=qIZsV0jdsikgNaaW3UjYdczhsVhjkpQPhPqaU2bZcZeY= #=zDhtUuHA=)
   at #=q1qifqgbfO3$0lc0sUiNkrfD41PlaQOxJx055JuE8yN4=.#=zlCDwa_IEDCXBmrjzhlG2YB1qUKX7ZuAEDQ==()
   at #=q1qifqgbfO3$0lc0sUiNkrfD41PlaQOxJx055JuE8yN4=.#=zcPspT3FgxW44vDiFAtot9leE4fBUxNmSig==(Boolean #=zNNPnWh0=)
   at #=q1qifqgbfO3$0lc0sUiNkrfD41PlaQOxJx055JuE8yN4=.#=z8Z9l9_sJ62wjsQAg0pnkD3gdbc2HPkyPT6YWJc0=(Object #=zNNPnWh0=)
   at #=q1qifqgbfO3$0lc0sUiNkrfD41PlaQOxJx055JuE8yN4=.#=zfvPDc8eLwDnY4EhV1sNz1WRdJbZeXytPd2XGYolD4HJV()
   at #=q1qifqgbfO3$0lc0sUiNkrfD41PlaQOxJx055JuE8yN4=.#=zlJoJcfx0ZpZ2sR7qZsJ5AMZUfnyc8fiJjA==(#=q1qifqgbfO3$0lc0sUiNkrfD41PlaQOxJx055JuE8yN4= #=zNNPnWh0=, #=qIZsV0jdsikgNaaW3UjYdczhsVhjkpQPhPqaU2bZcZeY= #=zDhtUuHA=)
   at #=q1qifqgbfO3$0lc0sUiNkrfD41PlaQOxJx055JuE8yN4=.#=zlCDwa_IEDCXBmrjzhlG2YB1qUKX7ZuAEDQ==()
   at #=q1qifqgbfO3$0lc0sUiNkrfD41PlaQOxJx055JuE8yN4=.#=zcPspT3FgxW44vDiFAtot9leE4fBUxNmSig==(Boolean #=zNNPnWh0=)
   at #=q1qifqgbfO3$0lc0sUiNkrfD41PlaQOxJx055JuE8yN4=.#=z8Z9l9_sJ62wjsQAg0pnkD3gdbc2HPkyPT6YWJc0=(Object #=zNNPnWh0=)
   at #=q1qifqgbfO3$0lc0sUiNkrfD41PlaQOxJx055JuE8yN4=.#=zfvPDc8eLwDnY4EhV1sNz1WRdJbZeXytPd2XGYolD4HJV()
   at #=q1qifqgbfO3$0lc0sUiNkrfD41PlaQOxJx055JuE8yN4=.#=zCBpRGWKD7yRbIwBuPUpufqEOynMU(Object #=zNNPnWh0=, UInt32 #=zDhtUuHA=)
   at #=q1qifqgbfO3$0lc0sUiNkrfD41PlaQOxJx055JuE8yN4=.#=zcPspT3FgxW44vDiFAtot9leE4fBUxNmSig==(Boolean #=zNNPnWh0=)
   at #=q1qifqgbfO3$0lc0sUiNkrfD41PlaQOxJx055JuE8yN4=.#=zcPspT3FgxW44vDiFAtot9leE4fBUxNmSig==(Boolean #=zNNPnWh0=)
   at #=q1qifqgbfO3$0lc0sUiNkrfD41PlaQOxJx055JuE8yN4=.#=zdgcY4DZxPNd$tKJOYdfnbK5AuT_nx6n5F4_WZZE=(Object[] #=zNNPnWh0=, Type[] #=zDhtUuHA=, Type[] #=zu_0e99I=, Object[] #=z8f8CWyY=)
   at #=q1qifqgbfO3$0lc0sUiNkrfD41PlaQOxJx055JuE8yN4=.#=zHfDFLGw50LDWmk44hN3or3ABeRJicZ$SVQ==(Stream #=zNNPnWh0=, String #=zDhtUuHA=, Object[] #=zu_0e99I=)
   at #=q1qifqgbfO3$0lc0sUiNkrfD41PlaQOxJx055JuE8yN4=.#=zebLYrXpzuaZTVwKXkZX31K$rP_$ASGhQqGHUjmU=(Stream #=zNNPnWh0=, String #=zDhtUuHA=, Object[] #=zu_0e99I=)
   at Aspose.Pdf.Document.#=zHSU7TJ1r2p51(Stream #=zrzqVF2Y=, SaveOptions #=zZd9LooIUKdl_)
   at Aspose.Pdf.Document.Save(Stream output)
   at MetadataProcessor.MetadataFileProcessor.EmptyPdfProperties(Stream stream) in /__w/1177/s/document-metadata-processor/MetadataProcessor/MetadataFileProcessor.cs:line 182
   at MetadataProcessor.MetadataFileProcessor.Strip(Stream stream, String mimeType) in /__w/1177/s/document-metadata-processor/MetadataProcessor/MetadataFileProcessor.cs:line 140
   at PdfMetadataStripper.Test.ParseOpenXML.StrippingPdf_RemovesMetadata() in /__w/1177/s/document-metadata-processor/MetadataProcessor.Test/MetadataFileProcessor.cs:line 58

This works fine on my windows machine, however its erroring in Docker.
I do not think its font related, we have the following in our base image:

Step 8 MS Fonts

RUN apt-get install -y cabextract fontconfig && \
    cd /tmp && \
    curl -o webfonts.tar.gz https://xxxxx/artifactory/local-third-party-generic/webfonts.tar.gz && \
    tar -xzf webfonts.tar.gz && \
    cd msfonts/ && \
    cabextract *.exe && \
    mkdir -p /usr/share/fonts/truetype/msfonts && \
    cp *.ttf *.TTF /usr/share/fonts/truetype/msfonts && \
    fc-cache -f /usr/share/fonts/truetype/msfonts

Any help would be very much appreciated!

Thank you

@oitani

Please attach your input PDF here for testing. We will investigate the issue and provide you more information on it.

Document.pdf (29.3 KB)

@tahir.manzoor Here is the pdf file that we are using.

Thanks

@oitani

We have logged this problem in our issue tracking system as PDFNET-52039. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hello @tahir.manzoor

Are there any updates with regards to the issue raised?

Thanks

@oitani

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

Has this been resolved?

@gauravnagar

We are afraid that the earlier logged ticket has not been yet resolved due to other pending issues in the queue. We will surely inform you once we make some significant progress towards ticket resolution. We apologize for the inconvenience.