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 Nov 06, 2019 1:23 am

Hello,

I am merging multiple documents into a pdf using Spire and part of our requirement is that we can use this merged pdf and merge it with other pdfs, but if excel information is present in a merged pdf when attempting to merge it again I am receiving this error:
at Spire.Pdf.PdfPageBase.get_CropBox()
at Spire.Pdf.Widget.PdfPageCollection.Add(PdfDocumentBase A_0, PdfPageBase A_1, List`1 A_2)
at Spire.Pdf.PdfNewDocument.ClonePage(PdfDocumentBase ldDoc, PdfPageBase page, List`1 destinations)
at Spire.Pdf.PdfDocumentBase.ImportPageRange(PdfDocumentBase ldDoc, Int32 startIndex, Int32 endIndex)
at Spire.Pdf.PdfDocumentBase.ᜋ(PdfDocumentBase A_0)
at Spire.Pdf.PdfDocumentBase.ᜀ(Stream[] A_0)
at Spire.Pdf.PdfDocument.MergeFiles(Stream[] streams)

This is an essential part of our process and would appreciate any help in resolving this issue.

I have attached an example Excel document and a merged pdf with excel information present to help with any merging testing.

KShubert
 
Posts: 7
Joined: Mon Sep 09, 2019 4:42 pm

Wed Nov 06, 2019 7:01 am

Hi,

Thanks for your inquiry.
How do you merge your PDF files into one PDF file? In your attachment, there is only one PDF. I used following code to merge your PDF file, there is no error. Everything worked fine.
Code: Select all
            string path1 = path + @"MergedWordandExcel.pdf";
            string path2 = path + @"MergedWordandExcel.pdf";
            string output = "19466.pdf";
            //use your original file twice
            PdfDocumentBase doc = PdfDocument.MergeFiles(path1, path2);
            doc.Save(output);


Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Nov 06, 2019 6:40 pm

Hello,

I should have specified I am merging a list of files from a MemoryStream.

Code: Select all
//mergeList is a list of PDFs in MemoryStreams
PdfDocumentBase result = PdfDocument.MergeFiles(mergeList.ToArray());
                    result.Save(masterPDFFile, Spire.Pdf.FileFormat.PDF);


Edit:
I have done some more testing with a much simpler test.

Code: Select all
PdfDocumentBase result = PdfDocument.MergeFiles(Directory.GetFiles(folderPath));
            result.Save(folderPath + "\\New-Merged.pdf", Spire.Pdf.FileFormat.PDF);


With the attached pdfs in the LocalTest Folder it will work the first time but if I attempt to merge again (changing the output name aswell) it is failing.

KShubert
 
Posts: 7
Joined: Mon Sep 09, 2019 4:42 pm

Wed Nov 06, 2019 9:18 pm

I have resolved my issue by updating to the most recent HotFix for Spire.Pdf (5.11.0)

KShubert
 
Posts: 7
Joined: Mon Sep 09, 2019 4:42 pm

Thu Nov 07, 2019 1:33 am

Hi,

Thanks for your feedback.
Please feel free to contact us if there is any question.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.PDF