We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Merge PDF out of memory exception

Hi,

We are using Aspose.pdf v19.2 library to merge PDF files. We found it will through out of memory exception when merging a 600MB PDF file with other pdf. Our machine is Win10 i3 with 3GB memory.

Here’s our code:
// Open first document
Document pdfDocument1 = new Document(“Concat1.pdf”);
// Open second document
Document pdfDocument2 = new Document(“Concat2.pdf”);

// Add pages of second document to the first
pdfDocument1.Pages.Add(pdfDocument2.Pages);

// Save concatenated output file
pdfDocument1.Save(“ConcatenatePdfFiles_out.pdf”);

Here’s our test file:
https://drive.google.com/file/d/14EyKJDK2PRPRoFPqCiPDwf8IsYRQdUD3/view?usp=sharing

FYI, we used Adobe Arcobat X Pro to merge the pdf file and it won’t throughout the memory exception.

Please have a look. Thanks.

@Glority_Developer

Thank you for contacting support.

We have worked with the data shared by you and concatenated it with a small PDF document. The process consumed around 2 GB of memory in about 3.5 minutes without any exception with Aspose.PDF for .NET 19.3. Would you please share your observations regarding memory and time consumption with Adobe Acrobat that works fine in your environment.

Here’s our system info:
image.jpg (80.3 KB)

Here’s another PDF file that we are merging it with the 600MB file
https://drive.google.com/file/d/1pVNq-wCaRtNQKJihlO3OdBb0XEGZ7J1P/view?usp=sharing

Notes, it will take around 1.23min to merge the two pdfs and then through out of memory exception. It will occupy 374MB memory.

@Glority_Developer

We have tried to concatenate both files shared by you and it has now consumed about 5 minutes and more than 2GB of memory before program finishes successfully. Please try to execute the code in x64 Debug Mode and then share your kind feedback with us.