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.

Wed May 26, 2021 4:06 pm

Hi. I am using Spire.PDF 7.5.7. I have about 700 PDFs and we want to do a check to make sure that all of the PDFs have the required number of pages. So I am using the code below to get the pageCount of each PDF to display it in our UI, but it is very slow. It took about 7 minutes to run. I tried using the same PdfDocument object for all files, but that only increased the performance to 5.5 minutes. Is there a better approach to get the page count for a large number of files?


foreach(var fileName in files)
{
int pageCount = -1;
...

using (PdfDocument document = new PdfDocument())
{
document.LoadFromFile(fileName);
pageCount = document.Pages.Count;
document.Close();
}

...
}

BFeldman
 
Posts: 9
Joined: Wed May 26, 2021 2:54 pm

Thu May 27, 2021 6:59 am

Hello,

Thank you for your inquiry.
I simulated your case almost 700 PDF files on my side, but it didn't take as long as yours. Actually, many factors have influence on the time-consuming, such as your PDF files, test environment. Our Spire.PDF needs parsing document data when loading, this process will cost time. To help us better investigate your issue, please provide your 700 PDF files (you could upload them by DropBox or OneDrive then share the download link), your test environment, such as OS info (E.g. Windows7, 64bit) and region setting (E.g. China, Chinese), and your application type such as Console app (.NET Framework 4.5). You could attach them here or send to us via email (support@e-iceblue.com). Thanks in advance.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Thu May 27, 2021 2:25 pm

Unfortunately, I cannot provide the PDFs since they contain sensitive information, but they are each 7 pages long, in English, about 230KB each if that helps. I am using a WPF app, .NET framework 4.7.2 on a Windows 10 Enterprise 64-bit system. Please let me know if you need any more information.

BFeldman
 
Posts: 9
Joined: Wed May 26, 2021 2:54 pm

Fri May 28, 2021 6:07 am

Hello,

Thank you for your feedback.
I simulated your files and tested with the same environment as yours, but it only took about 30 seconds. I guess that the reason is that our product takes a lot of time to parse some of the data in your PDF documents. Hence, please provide your testing PDF files so that we can accurately test your issue and investigate if the time could be optimized. We promise to keep your document confidential and we will not use it for any other purpose. Besides, you could also remove the security data from your document. You could upload them by DropBox or OneDrive then share the download link with us (support@e-iceblue.com). Thanks in advance.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Fri May 28, 2021 2:27 pm

Hi,

I scrubbed one of our PDFs for sensitive information. Please see the attached. You can duplicate this 700 times and try it. I am wondering if the images in the page headers has something to do with it. Thanks for your help!


Best Regards,
Ben

BFeldman
 
Posts: 9
Joined: Wed May 26, 2021 2:54 pm

Mon May 31, 2021 9:58 am

Hi,

Thanks for your sharing.
I copied 700 files of your PDF file to test your case, it still only took about 28 seconds. I uploaded my test demo for your reference, you could try it on your side and then tell us the time it costs. Look forward to your reply.
http://www.e-iceblue.com/downloads/demo/GetPdfPageNumber.zip

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Tue Jun 01, 2021 4:21 pm

Hi,

I tried your sample project and it finished in 14 seconds for me. Then I pointed it to my prod files and it still took several minutes. I realized then that the issue is network latency issue since those prod files are on a network drive. I moved the sample PDFs to the network drive and reran the sample project to point to those sample PDFs and it also took several minutes. So it is not an issue with Spire. I appreciate your help in debugging this with me. You can mark the issue as closed and I can see what I can do about copying the files locally first or other workarounds.


Best Regards,
Ben

BFeldman
 
Posts: 9
Joined: Wed May 26, 2021 2:54 pm

Wed Jun 02, 2021 2:00 am

Hello,

Thank you for your feedback.
If you have other questions about using Spire.PDF in the future, please feel free to contact us.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.PDF