Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Feb 03, 2026 12:27 pm

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.

LauraNM
 
Posts: 92
Joined: Tue Feb 19, 2019 1:23 pm

Wed Feb 04, 2026 6:23 am

Hello,

Thank you for your post.

PdfDocument.MergeFiles(streams) merges all specified documents into a new document. The larger the documents, the more memory this operation requires, and higher memory consumption can also impact CPU usage. For merging large documents, we recommend the following two approaches:
1. Increase the server's available memory.
2. Split large documents into smaller ones and merge them in batches.

We look forward to your further feedback.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3008
Joined: Wed Jun 27, 2012 8:50 am

Wed Feb 04, 2026 11:06 am

Hello,

Thank you for your response.

We understand that merging large PDF documents requires significant memory and can impact CPU usage. However, we would like to better understand how to apply batching in an optimal way without unnecessarily degrading performance.

Could you please clarify:

1. From your experience, starting at approximately what PDF file size do you recommend switching to a batch-based approach instead of processing the document in a single operation?
For example, is batching recommended above 100 MB, 200 MB, 250 MB, etc.?

2. Could you provide a simple code example showing how to:
- Save large PDF documents using SaveToStream in batches.
- Merge large PDF documents using PdfDocument.MergeFiles in batches.

Having official examples would help us ensure we are using Spire.PDF in the most efficient and supported way, especially for large documents.

Thank you very much for your assistance.

LauraNM
 
Posts: 92
Joined: Tue Feb 19, 2019 1:23 pm

Thu Feb 05, 2026 8:34 am

Hello,

Thank you for your follow-up inquiry.

I’ve discussed your issue with our development team. Regarding merging large documents into a single file, even if you merge them in batches, the final step still requires loading large documents into memory for consolidation. Ultimately, the most effective approach is to increase the system's available memory.

Would you be able to share more about your specific use case or purpose for merging these large documents into one file? With a better understanding of your end goal, we might be able to suggest an alternative solution that achieves the same result without requiring a full merge into a single document.

We look forward to your feedback.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3008
Joined: Wed Jun 27, 2012 8:50 am

Thu Feb 05, 2026 9:35 am

Thank you for your response and for consulting with your development team.

Our use case requires merging multiple large documents that we receive from external sources. It is common for us to receive several files larger than 300 MB each, and we need to merge them into a single document as part of our processing workflow.

However, we are encountering issues not only with SaveToStream, but also during the merge process itself when handling large files. The merge operation becomes extremely slow or does not complete when processing very large documents.

Additionally, when using the SaveToStream method, the process freezes and never completes. It stays blocked at that point indefinitely and does not produce any output.

We have also observed that overall performance is significantly slower compared to previous versions of the library, even when working with smaller files. This performance degradation is affecting our system throughput.

Increasing system memory is not always a viable solution for us, as these processes run in production environments with predefined resource limits.

Could you please advise if there is:

A recommended approach for handling very large document merges efficiently

Any configuration, optimization, or alternative API method that avoids loading the entire document into memory

Known issues or limitations when merging very large documents

Known issues with SaveToStream freezing when handling large files

We look forward to your guidance.

LauraNM
 
Posts: 92
Joined: Tue Feb 19, 2019 1:23 pm

Thu Feb 05, 2026 10:05 am

Hello,

Thank you for your prompt response.

I have already relayed your concerns to our development team again. We will take some time to investigate and get back to you with feedback.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3008
Joined: Wed Jun 27, 2012 8:50 am

Fri Feb 06, 2026 9:22 am

Hello,

The tracking ID for this inquiry is SPIREPDF-7958. We will keep you updated on the progress in a timely manner. Thank you for your understanding and support.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3008
Joined: Wed Jun 27, 2012 8:50 am

Fri Feb 06, 2026 10:06 am

Thank you very much!

LauraNM
 
Posts: 92
Joined: Tue Feb 19, 2019 1:23 pm

Thu Apr 02, 2026 10:06 am

Hello,

Thank you for your patience.

We have implemented some improvements on memory usage when merging large documents. Welcome to download and test [Spire.PDF
Pack(Hotfix) Version: 12.4.0].
Our website link: https://www.e-iceblue.com/Download/download-pdf-for-net-now.html
NuGet link:
https://www.nuget.org/packages/Spire.PDF/12.4.0
https://www.nuget.org/packages/Spire.PDFfor.NETStandard/12.4.0

If you have any questions, please let us know.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3008
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.PDF

cron