Merge PDF Issue (ASPOSE.PDF) File Size around 10 GB

Hi Team,

we are facing issue while merging large pdf files , count is 10. Each file size around 1 GB and we need to merge into single pdf file. Final pdf will be around 10 GB.

we have tried two approaches"

AllpdfFilesCollection = new List();
AllpdfFilesCollection.Add(@“D:\Main\ServiceTier\BatchPrintApplication\pdf\1.pdf”);
AllpdfFilesCollection.Add(@“D:\Main\ServiceTier\BatchPrintApplication\pdf\2.pdf”);
AllpdfFilesCollection.Add(@“D:\Main\ServiceTier\BatchPrintApplication\pdf\3.pdf”);
AllpdfFilesCollection.Add(@“D:\Main\ServiceTier\BatchPrintApplication\pdf\4.pdf”);
AllpdfFilesCollection.Add(@“D:\Main\ServiceTier\BatchPrintApplication\pdf\5.pdf”);
AllpdfFilesCollection.Add(@“D:\Main\ServiceTier\BatchPrintApplication\pdf\6.pdf”);
AllpdfFilesCollection.Add(@“D:\Main\ServiceTier\BatchPrintApplication\pdf\7.pdf”);

                    string _tempfinalfile = directory +  "FINAL_PDF" + "_" + DateTime.Now.Date.ToString("d").Replace("/", "_") + "tempFinalFile.pdf";
                    aspPDF.Document pdfDocument = new aspPDF.Document();

                    aspPDF.Document pdfDocument2 = null;

                    for (int i = 0; i < AllpdfFilesCollection.Count; i++)
                    {
                        string path2 = AllpdfFilesCollection[i];
                        pdfDocument2 = new aspPDF.Document(path2);
                        pdfDocument.Pages.Add(pdfDocument2.Pages);

                        pdfDocument2.Dispose();

                    }
                    pdfDocument.Save(_tempfinalfile);
                    pdfDocument.Dispose();

bool isSucceed = pdfEditor.Concatenate(filesArray, _tempfinalfile);

Note : filesArray collection of files

We are getting error : Exception of type ‘System.OutOfMemoryException’ was thrown.

@pransh.sharma

Can you please make sure that your application is targeting x64 mode of debugging? Please share the complete environment details where you are running this code snippet e.g. RAM Size, OS Name and Version, Application Type, .NET Framework Version, etc. We will further test the scenario in our environment and address it accordingly.

Hi Ali,

we have applied setup to targeting x64 mode of debugging.
Project properties > Build tab > Platform target : x64

But it’s not working for me, unable to merge 10 GB pdf file. Process still running from 3 hours.
Please suggest.

Configuration :

RAM : 16 GB
System Type : 64 bit operating system, x64 based processor
Window 10 enterprise
Processor : Intel Core i5, 2.10 GHz

Microsoft Visual Studio Professional 2015
Version 14.0.25431.01 Update 3

Microsoft.Net Framework
Version 4.8.03752

Application Type : Console Application c#

Thanks

@pransh.sharma

We tested the scenario in our environment using Aspose.PDF for .NET 21.5 and one of our sample files. We did not notice the memory consumption issue and the program took 10 minutes to generate the output. We used the below code snippet (do not dispose of the document which pages you are adding as it needs to remain open until destination document is saved);

Document pdfDocument1 = new Document();
for (int i = 0; i < 10; i++)
{
 string path2 = dataDir + "1GB_File.pdf";
 var doc2 = new Document(path2);
 pdfDocument1.Pages.Add(doc2.Pages);
 //doc2.Dispose();
}
pdfDocument1.Save(dataDir + "output.pdf");

Would you please make sure that you are using the 21.5 version of the API? Also, please check how much time API is taking while processing every document. Is it taking more time while processing any specific file in the collection? Please try to upload any sample PDF to Dropbox or Google Drive and share the link with us. We will again test the scenario in our environment and address it accordingly.