Free Support Forum - aspose.com

Merge - but save in diff. documents

Hi,

Is it possible to merge to ei. 100 docs, and save them as 100 sep. files instead of one big file?

Mac

Hi Mac,

Thank you for considering Aspose.

Sorry, could you please elaborate you question? I think I misunderstood you - otherwise why don’t just use a loop?

The best way to do this is:

// Open the document
Document srcDoc = new Document(myFile);

//Loop through all your data records (could be in a DataTable or in an array)
foreach (DataRow row in myDataTable.Rows)
{
//Cloning document in memory is faster than reading it from file each time.
Document dstDoc = srcDoc.Clone();

dstDoc.MailMerge.Execute(row);
dstDoc.Save(GenerateUniqueFileName(myFile, row));
}