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 Mar 18, 2025 7:42 am

Hi Team,

We are currently using SpirePDF for watermarking and processing PDF documents. For small files, it works well.
However, for larger files (100+ pages), we are facing memory consumption issues.
We understand that SpirePDF supports loading PDFs from streams (e.g., FileStream, MemoryStream), but we would like to confirm:

Does SpirePDF internally load the entire PDF into memory from the stream, or
does it support true streaming-based processing from disk without fully loading the file into RAM?

If stream-based disk processing is supported, could you kindly share documentation or guidance on how to implement that for large PDF files?

Thank you.
Best Regards,
Leo

nvdr.licenses
 
Posts: 3
Joined: Fri Feb 03, 2023 2:40 pm

Wed Mar 19, 2025 1:39 am

Hello,

Thanks for your inquiry.
Please be aware that Spire.PDF needs to load the document into memory for processing. Memory consumption often depends on the content of the document. The more complex the content, the more memory is consumed. We currently do not support stream-based disk processing. Thank you for your understanding.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 757
Joined: Mon Dec 27, 2021 2:23 am

Wed Mar 19, 2025 7:46 am

William.Zhang wrote:Hello,

Thanks for your inquiry.
Please be aware that Spire.PDF needs to load the document into memory for processing. Memory consumption often depends on the content of the document. The more complex the content, the more memory is consumed. We currently do not support stream-based disk processing. Thank you for your understanding.

Sincerely,
William
E-iceblue support team


Hi William,

Thanks for your reply.

Is there any possibility to process a large PDF in segments (e.g., page ranges) to reduce memory overhead, even if it doesn't equate to true streaming. Could you provide guidance on optimizing memory usage when processing complex PDFs? Are there any recommended configuration settings or best practices for handling large documents?

Also, are there any plans or a roadmap for introducing stream-based or incremental processing in future releases of Spire.PDF

nvdr.licenses
 
Posts: 3
Joined: Fri Feb 03, 2023 2:40 pm

Wed Mar 19, 2025 10:03 am

Hello,

Thanks for your reply.
Sorry, I'm afraid we currently don't have a suitable solution for large documents. As I mentioned before, memory consumption depends on the content of the document. For your scenario, if the document does not contain a large number of images, tables, etc., a document of over 100 pages should not occupy too much memory. You can provide us with your documentation and related test code, and we will further investigate whether we can optimize memory consumption.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 757
Joined: Mon Dec 27, 2021 2:23 am

Fri Apr 04, 2025 8:21 am

William.Zhang wrote:Hello,

Thanks for your reply.
Sorry, I'm afraid we currently don't have a suitable solution for large documents. As I mentioned before, memory consumption depends on the content of the document. For your scenario, if the document does not contain a large number of images, tables, etc., a document of over 100 pages should not occupy too much memory. You can provide us with your documentation and related test code, and we will further investigate whether we can optimize memory consumption.

Sincerely,
William
E-iceblue support team


Hi William, please find the test code attached. Thank you.
Watermark.zip

nvdr.licenses
 
Posts: 3
Joined: Fri Feb 03, 2023 2:40 pm

Mon Apr 07, 2025 10:28 am

Hello,

Thanks for your reply and sorry for the late reply.
I noticed that you seem to split the large file into many small files and then add the watermark. I am afraid this will not reduce the memory usage. Have you tried to add the watermark directly to the large file? In addition, can you simplify the code and provide us with a project that can be run directly? This will help us locate the problem faster. Thanks in advance.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 757
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.PDF