System.OutOfMemoryException while merging multiple pdfs

Technical support for Spire.PDF

Moderator: iceblue support

System.OutOfMemoryException while merging multiple pdfs

Postby vktewthia » Mon Jul 24, 2017 3:11 pm

Hi,
I am getting System.OutOfMemoryException when trying to merge multiple pdfs with Spire.pdf. I am using latest build (Spire.PDF Pack(Hot Fix) Version:3.9.82).
I have tried two approaches (1) with AppendPage and (2) with MergeFiles. In both cases I am getting same exception. I have calculates that all files could sum up to the size of 230 MP approax.

Given below is the code I am using, Please help me.

Code: Select all
foreach (var file in files)
                {
                    var filePath = string.Format("{0}{1}.pdf", targetLocationPath, file);

                    if (File.Exists(filePath))
                    {
                        mainPdfDocument.AppendPage(new PdfDocument(filePath));

                    }
                }

                mainPdfDocument.SaveToFile(mainFileStringPath, Spire.Pdf.FileFormat.PDF);


and
Code: Select all
var newPdf = PdfDocument.MergeFiles(files.Select(s => string.Format("{0}{1}.pdf", targetLocationPath, s)).ToArray());
newPdf.Save(mainFileStringPath);
vktewthia
 
Posts: 1
Joined: Thu Mar 02, 2017 8:16 am

Re: System.OutOfMemoryException while merging multiple pdfs

Postby Betsy.jiang » Tue Jul 25, 2017 1:37 am

Dear vktewthia,

Thanks for your inquiry.
Now the latest version is Spire.PDF Pack(Hot Fix) Version:3.9.226, we suggest upgrading to this version to check if the issue is solved. If it still happens, due to the memory usage is completely dependent on document size and document complexity, please offer us the input files here or send it to us(support@e-iceblue.com) via email for investigation.

Sincerely,
Betsy
E-iceblue support team
User avatar
Betsy.jiang
 
Posts: 1637
Joined: Tue Sep 06, 2016 8:30 am


Return to Spire.PDF

Who is online

Users browsing this forum: No registered users and 1 guest