Hello,
I am using Spire.Office for .NET Standard, version 10.11.0, and I am experiencing performance issues when working with very large PDF files.
Issue description
When processing large PDFs (larger than 250 MB), the application hangs or throws an error in the following scenarios.
Unfortunately, I cannot attach sample files due to confidentiality restrictions, but this issue occurs consistently with any PDF file exceeding this size.
1. Using PdfDocument.MergeFiles
2. Using SaveToStream
// Replace these paths with any PDF files larger than 250 MB
string[] inputFiles =
{
@"C:\Temp\LargePdf1.pdf",
@"C:\Temp\LargePdf2.pdf"
};
MemoryStream[] streams = new MemoryStream[inputFiles.Length];
for (int i = 0; i < inputFiles.Length; i++)
{
streams[i] = new MemoryStream();
using (FileStream fs = new FileStream(inputFiles[i], FileMode.Open, FileAccess.Read))
{
PdfDocument pdf = new PdfDocument(fs);
pdf.SaveToStream(streams[i]);
}
}
MemoryStream output = new MemoryStream();
PdfDocumentBase merged = PdfDocument.MergeFiles(streams);
merged.Save(output);
With large files, the process either freezes or fails during the save operation.
Additionally, when this happens, the server CPU usage increases to 100%, causing the server to become unresponsive.