Slow in building a document



I'm trying to build a document with Aspose.Words which contains more than 100 pages. But the building of this page isn't very fast. It takes quite a while to build, and somethings it also makes the session to drop.

I'm building with the starttable, insertcell, endrow, etc etc commands. Is there a more efficient way to produce documents with a lot of pages ??

Greetz Johan Jansma


Generally, we don't recommend building documents dynamically, especially such a big documents. It is much more efficient to generate documents based on premade templates. But we will research the issue of course.

Please attach a sample project. I will check if the code could be optimized or if we can make some optimizations in the library.

Best regards,


You probably have a table with a lot rows of a same type, just different data. If so, use mailMerge.


With mail merge the template grows automatically duplicating template content for each record of merge data source. See our demo projects, for example 'DinnerInvitation' document generation. The process of doing MailMerge with Aspose.Words is described in details in our wiki documentation:

The same articles can also be found in the documentation that comes with the setup package.

Best regards,


The example DinnerInvitation doesn't have multiple rows within a page, does it ??

In my example, at the headers kadastrale gegevens and object onderdelen, the rows are also dynamically created. How to deal with that ??

Gr Johan


The dynamic creation of mail merged rows is supported via MailMerge.ExecuteWithRegions method. See related articles in our help. It is also demonstrated in demos (ProductCatalogDemo, SalesInvoiceDemo, EmployeesReportDemo).

Best regards,


I’m going to try something with the ProductCatalogDemo. Think this could be a solution…



Another problem occured because i'm using MailMerge now. How do i convert a date from the format jjjjmmdd to dd-mm-jjjj ??

Gr Johan


You can use the so called "picture switches" for that. Here is an excerpt from MS Word help with instructions:

Change other formatting by using field codes

To control other aspects of formatting, press ALT+F9 to display field codes in the main document, and then add switches to the merge fields.

For example:

  • To display the number "34987.89" as "$34,987.89," add a numeric picture switch (\# $#,###.00).
  • To display the number "0945" as "9:45 PM," add the date/time picture switch (\@ "h:mm am/pm").
  • To ensure that the merged information has the same font and point size you apply to the merge field, add the \* MERGEFORMAT switch.

Hope that helps,