Pdfdoc.save getting "Stream was too long" exception on .Net

Product: PdfTron .Net x64

Product Version: 9.5.0

Please give a brief summary of your issue:
A call to pdfDoc.Save is getting a System.IO.IOException with the error message “Stream was too long”

Please describe your issue and provide steps to reproduce it:
I have a method that builds a pdfDoc composed of 46 other PDF documents (being read as streams) to combine them into a single PDF. Some of these are fairly large (70-90 MB).

The relevant stack trace looks like this:
Type: System.IO.IOException
Source: System.IO.MemoryStream, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
Message: Stream was too long.
Trace:
at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.Stream.CopyTo(Stream destination, Int32 bufferSize)
at pdftron.PDF.PDFDoc.ReadFully(Stream input)
at pdftron.PDF.PDFDoc.Save(SaveOptions flags)

I’m assuming the problem is because on .Net the MemoryStream has some limit on the size of memory buffer it can handle but my question is how to up the limit to handle very large PDFs?
My use case is that we’re feeding these combined PDF documents into large-format printers (think images 10 feet by 150 feet) so we need to compose these giant PDF documents, regardless of how many bytes they end up being.

Hi phred.menyhert,

Thank you for reaching out.
I will present the query to our Core team, and will contact you once we have more information.

Hello phred.menyhert,

For large documents, we suggest using the save method with a file path. This is to ensure that there are no problems when trying to deal with large amounts of memory.

You can find the documentation for saving on PDFDoc page: Class PDFDoc