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 22, 2022 11:15 am

Hello,

In our application we call the RemoveAt method of the PdfPageCollection class to remove a specified PDF page at a specified index (file size about 35 MB).

outputDocument.Pages.RemoveAt(pageCount - 1);

After solving a previous issue, that was preventing our program to arrive at the RemoveAt method before, we found that this method is throwing a NullReferenceException.

Stack trace:
System.NullReferenceException: Object reference not set to an instance of an object.
at Spire.Pdf.Widget.PdfPageCollection.ᜀ(Int32 A_0, PdfPageBase A_1)
at Spire.Pdf.Widget.PdfPageCollection.RemoveAt(Int32 index)

Are we using the method correctly? Or could there be an issue with the RemoveAt method in the PdfPageCollection that you know of? Please advise.

Thank you,
Aella

aellawaai
 
Posts: 5
Joined: Fri Feb 04, 2022 2:25 pm

Wed Feb 23, 2022 1:36 am

Hello,

Thank you for your inquiry.
According to your description, I did an initial test, but did not reproduce the problem you mentioned. To help us investigate your issue quickly and efficiently, please provide the following information. You could attach them here or send them to us via email ([email protected]). Thanks in advance.
1) Your input PDF file.
2) Your complete test code.
3) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).
4) Your application type, such as Console app (. Net Framework 4.5).

Sincerely,
Annika
E-iceblue support team
User avatar

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

Wed Feb 23, 2022 5:35 pm

Hello Annika,

Thank you for your reply. I'll get back to you with more information as soon as possible.

Best,
aella

aellawaai
 
Posts: 5
Joined: Fri Feb 04, 2022 2:25 pm

Thu Feb 24, 2022 6:05 am

Hello,

Okay. We look forward to your further information.

Sincerely,
Annika
E-iceblue support team
User avatar

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

Thu Mar 10, 2022 9:22 am

Hello,

I want to let you know that we found that the Pages.RemoveAt() function cannot handle pdf bookmarks in our project. So if the pdf document contains a bookmark on the page to be removed, the function throws a NullReferenceException.

We solved the issue by removing all bookmarks, since we didn't need them, but it may be worth investigating this issue further for other users of Spire.PDF.

Best wishes,
aella

aellawaai
 
Posts: 5
Joined: Fri Feb 04, 2022 2:25 pm

Thu Mar 10, 2022 9:59 am

Hello,

Thanks for your feedback.
I simulated a PDF file with bookmarks and did an initial test, but still did not reproduce the issue you mentioned. The version I used is the latest Spire.PDF (Spire.PDF Pack(Hot Fix) Version:8.2.2). If you were not using the latest version, please first give it a try. If the issue still exists after trying, please provide the following information. You could attach them here or send them to us via email ([email protected]). Thanks in advance.
1) Your input PDF file.
2) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).
3) Your application type, such as Console app (. Net Framework 4.5).

Sincerely,
Annika
E-iceblue support team
User avatar

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

Return to Spire.PDF

cron