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

Free Support Forum - aspose.com

Need help to Merge PDF using foreach


I’m Newbies using Aspose.Pdf. Still Under Evaluation. This is my question,

I retrive all my Pdf using this code

// Find all pdf documents in input folder.
DirectoryInfo directoryInfo = new DirectoryInfo(Server.MapPath(trnxFolder + “//” + Session[“generate_batch_Id”].ToString()));
FileInfo[] allPDFs = directoryInfo.GetFiles(".pdf");

I read all Pdf document using foreach as follow,
foreach (FileInfo fileInfo in allPDFs)


Need help to apply

Document pdfDocument1 = new Document(dataDir + “Concat1.pdf”);

in Looping


How to save Pdf in One File?

mergedDocument.Save ??

Please help

Hi Sharul,

Thanks for contacting support.

Once you have the reference of all the documents inside directory, you may set one PDF file as base document/first document and then start adding the pages of subsequent documents to pages collection of main/base document. For more information, please visit Concatenate PDF Files

In case you still face any issue or you have any further query, please feel free to contact.