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.

Fri Mar 05, 2021 10:14 pm

For some reason we have a couple instances of particular pdfs that are causing a crash when we are trying to merge them into another pdf. This only occurs when they are appended into pdf which is then merged into another. The error message is:

Object reference not set

at Spire.Pdf.PdfDocumentBase.ImportPageRange(PdfDocumentBase ldDoc, Int32 startIndex, Int32 endIndex)
at Spire.Pdf.PdfDocumentBase.ᜃ(PdfDocumentBase A_0)

Example of the code that is causing the error (the bottom line is where the crash occurs):

Code: Select all

            PdfDocument fullDocument = new PdfDocument();
            PdfDocument fullListofExhibits = new PdfDocument();
            PdfDocument problemExhibit = new PdfDocument();

            //Create title page and put into mergedNarrative
            fullDocument.LoadFromFile(@"C:\Test\TitlePage.pdf");

            fullListofExhibits.LoadFromFile(@"C:\Test\ExhibitsCoverPage.pdf");

            problemExhibit.LoadFromFile(@"C:\Test\patient form child orthodontics.pdf");

            fullListofExhibits.AppendPage(problemExhibit);

            fullDocument.AppendPage(fullListofExhibits);



The specific file that is the problem is the patient form child orthodontics.pdf, which I can email if necessary. Thanks!

jimr0217
 
Posts: 6
Joined: Thu Mar 04, 2021 2:59 pm

Mon Mar 08, 2021 5:43 am

Hello,

Thanks for your inquiry.
To help us investigate your issue more accurately and quickly, please provide us with you input files. You can send them to us([email protected]) via email. Thanks in advance.

Besides, our Spire.PDF provides a new method to merge PDF files, you can give it a try.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Tue Mar 09, 2021 2:15 am

Hello Jim,

Thanks for providing your files via email.
I tested your case and did reproduce your issue. I have logged it in our bug tracking system with the ticket SPIREPDF-4089. If there is any update, we will let you know, I am sorry for the inconvenience caused.

Besides, I have verified that using the following code to merge your documents, the application will not throw the exception. We recommend that you can use this method instead.
Code: Select all
            String[] files = new String[] { "TitlePage.pdf", "ExhibitsCoverPage.pdf", "patient form child orthodontics.pdf" };
            string outputFile = "result.pdf";
            PdfDocumentBase doc = PdfDocument.MergeFiles(files);
            doc.Save(outputFile, FileFormat.PDF);


Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Wed Mar 10, 2021 5:13 am

Thank you for your help! I was able to use the code you provided and the error no longer occurs.

jimr0217
 
Posts: 6
Joined: Thu Mar 04, 2021 2:59 pm

Wed Mar 10, 2021 8:05 am

You are welcome.
If you encounter any issues related to our products in the future, please feel free to contact us.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Wed Apr 14, 2021 10:11 am

Hello Jim,

Hope you are doing well.
Glad to inform you that we just released Spire.PDF Pack(Hot Fix) Version:7.4.5 which fixes your issue SPIREPDF-4089, please download it from the following links to test on your side. Looking forward to your testing result.
Website link: https://www.e-iceblue.com/Download/down ... t-now.html
Nuget link: https://www.nuget.org/packages/Spire.PDF/7.4.5

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.PDF