I am running mail merge repeatedly for the same document and at the end I am just appending to get the final output.
Here is my code snippet:
foreach (Client objClient in clientList)
mmDataSource = GetPropertyMailMergeDataSource(objClient, mergeFields);
objMailMergeDocument = objReportDocument.Clone(); //objReportDocument contains all merge fields
objMailMergeDocument.MailMerge.MergeField += new MergeFieldEventHandler(MailMerge_MergeField);
objMailMergeDocument.MailMerge.MergeImageField += new MergeImageFieldEventHandler(MailMerge_MergeImageField);
//Mail Merge Second Pass
objMailMergeDocument = ExecuteMailMergeSecondPass(objMailMergeDocument);
emailTo = objClient.EmailAddress.Address;
List reports = new List();
EmailUtility objEmailUtility = new EmailUtility(objReportRequest);
foreach (KeyValuePair<string, List> emailReport in emailReports)
foreach (Document objReport in emailReport.Value)
But when I am calling AppendDocument, it just hangs on after iteration and throws error after 5-6 mins:
"Exception of type ‘System.OutOfMemoryException’ was thrown."
FYI, Individual document that I was testing with - each contains 18 pages.
Is there any maximum no. of pages that an Aspose document can hold?
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thanks for your request. There is no limit of number of pages or document size. But you should note, when you open document using Apsose.Words, document object model is built in the memory. DOM always takes few times more memory that the original document size.
So maybe your document is too huge. I think, in your case, it is better to use few smaller documents instead of one huge document.