PdfDocument Save - System.NullReferenceException

I am working on a production support issue. We are using C# with Aspose.PDF (24.1.0). I do not have the file unfortunately. I realize that you cannot duplicate the issue without the PDF, but may I please know some common reasons for the error below? I cannot debug because the stack trace is obfuscated. Here is the scenario:

  1. The user uploads a file.
  2. We verify that the file is a content type of application/pdf.
  3. We move that pdf to a memory stream.
  4. An Aspose.Pdf.PdfDocument is instantiated with that memory stream.
  5. We combine multiple pdfs in that document if there are any more (in this case it was only the one pdf, so no combining happened).
  6. We use Aspose.Pdf.PdfDocument.Save to move the completed document to a new memory stream.

When we do that, this error below occurs:

System.NullReferenceException: Object reference not set to an instance of an object.
at Aspose.Pdf.Document.#=zdW1b$Ypt2eJ1()
at Aspose.Pdf.Document.#=zV9gkdScQ52R41SUKfg==()
at Aspose.Pdf.Document.#=zmScjVlWaug$v(Stream #=zi7IuvFA=, SaveOptions #=zMUYxo6mTQ6TK)
at Aspose.Pdf.Document.Save(Stream output)

@areinking
Is there any connection with the volume (size) of the resulting document?

There is not. I tried throwing as much data as we allow to handle. Most documents are under 1mb, but I threw 4 40mb at it to try to reproduce and I could not reproduce it.

@areinking
According to the stack trace, this is related to the resources of one of the XForms. There is a small chance that if you show the code used, something else can be added. But the optimal solution is to provide the code with the data on which the error occurs.
Try to delete/replace sensitive data in the document and perhaps you will be able to attach the document as well.