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.

Mon Feb 17, 2025 10:50 pm

Error occurs after PdfDocument.saveToFile: Object reference not set to an instance of an object
Maybe one of the source pdf has a permission password. would this be a problem?

\spire.pdf_11.2.4\BIN\NET4.0\Spire.Pdf.dll
used in .net framework 4.7.2 project

Dim fullFilenameL As String = "C:\Temp\out.pdf"
Dim newDocL As PdfDocument
newDocL = New PdfDocument()
newDocL.DocumentInformation.Creator = "xxx"
newDocL.DocumentInformation.Title = "yyyy"
For Each fileL As clsSpirePdfFileEntry In FileListM
Dim partDocL As New PdfDocument(fileL.FilenameFull)
newDocL.AppendPage(partDocL)
Next
' newDocL Document has 132 pages after the concatenation

newDocL.SaveToFile(fullFilenameL, FileFormat.PDF)
==>
Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt (Object reference not set to an instance of an object)
Stacktrace:
bei Spire.Pdf.Widget.PdfPageCollection.?(Int32 A_0, PdfPageBase A_1)
bei Spire.Pdf.PdfNewDocument.Save(Stream stream)
bei Spire.Pdf.PdfDocumentBase.Save(String fileName)
bei Spire.Pdf.PdfDocumentBase.Save(String fileName, FileFormat fileformat)

Wilfried.Engstler
 
Posts: 4
Joined: Thu Feb 13, 2025 2:13 pm

Tue Feb 18, 2025 2:49 am

Hi,

Thanks for your inquiry.
The document containing permission password is not the reason for the exception “Object reference not set to an instance of an object”. In order to further investigate and accurately locate the issue, we would like to obtain the testing documents you have used. You can upload them here or send them to my email ([email protected]).

Please rest assured that all provided information is only for troubleshooting purposes and will be strictly kept confidential. Thank you very much for your cooperation.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1290
Joined: Tue Sep 27, 2016 1:06 am

Tue Feb 18, 2025 9:41 am

thanks for your quick answer!!
here come the files i concatenated when getting the error

Wilfried.Engstler
 
Posts: 4
Joined: Thu Feb 13, 2025 2:13 pm

Tue Feb 18, 2025 10:17 am

Hi,

Thanks for your sharing.
I have tested the documents you provided and found that if license is not applied correctly, the problem you described may indeed occur. Could you please confirm if you have applied the license? I have also handed over the exception to the dev team for adjustment, and I will provide you with further feedback if there is any update.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1290
Joined: Tue Sep 27, 2016 1:06 am

Tue Feb 18, 2025 10:32 am

At the moment I am testing the lib, so I have only a trial version/license. I tried a simple function just opening a pdf and saving under another namem, that worked fine.

"Evaluation Warning : The document was created with Spire.PDF for .NET."

Do I need to install a trial license explicitly?

Wilfried.Engstler
 
Posts: 4
Joined: Thu Feb 13, 2025 2:13 pm

Wed Feb 19, 2025 2:24 am

Hi,

Thanks for your feedback.
Without applying license, there will be the red warning watermark and a restriction on converting 10 pages. Our sales team has already sent a temporary license (free for one month) to your email. Please refer to the following tutorial to apply the license key to remove warning watermark and merge exception.
How to Apply the License by license key

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1290
Joined: Tue Sep 27, 2016 1:06 am

Wed Feb 19, 2025 12:46 pm

Thank you very much,

The problem was solved after having installed the trial license

Kind regards
Wilfried Engstler

Wilfried.Engstler
 
Posts: 4
Joined: Thu Feb 13, 2025 2:13 pm

Thu Feb 20, 2025 2:01 am

Hi Wilfried,

You're welcome.
If you need assistance in the future, please feel free to contact us.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1290
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.PDF