Mail Merge with 100,000 pages (best approach and limitations)

Hey, I am planning to use aspose for Word mail Merge and my requirement is to generate 100,000 pages document after mail merge a word template (1 page template).

Document doc= new Document(“template\file.dotx”);

My client wants a single file for all 100,000 pages and I am trying with aspose.words for DOT NET latest version of library.

Dataset ds= new Dataset();

My dataset has 100,000 records to be merged with template.

Doc. MailMerge.Execute(ds);

This will allow me to merge all 100,000 records in template.

However I notice that we have couple of issues and need you guys input.

  1. Can we replace Dataset with String Arrays and how to merge 100,000 pages in a single file without compromising performance? Which is the best way for aspose to mail merge in this case? Which approach(datatable or string array) will take less time and memory? Please give me samples if you have.

  2. If I go with datatable while mail merges for over 50,000 Pages I am encountering Memory out of exception. Do you have any upper limit for no of pages or any such limitation when it comes to mail merging?

Please help

@mvanan

Thanks for your inquiry. Please note it is recommended to use Dataset instead of String Arrays when dealing with a tabular data/database. Furthermore, please use Mail Merge with regions for your requirement. It will create a single page for each record.

Mail Merge with Regions
How to execute Mail Merge with Regions

In reference to your second query, please note Aspose.Words does not limit number of pages and output file size. Aspose.Words processes document in memory, so it depends upon system resources. Usually Aspose.Words needs few times more memory than document size to build model of the document in memory. For example, if your document’s size is 1 MB, Aspose.Words needs 10-20 MB of RAM to build its DOM in memory.

If you are getting OutOfMemory exception for large data, then you can create multiple documents for small set of data e.g. a document for 10,000 records each and later append these documents to get a final output.