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

Free Support Forum - aspose.com

Mail Merge problem with numbered lists

Aspose Team,
I am using Aspose.Words version Attached is a zip file containing the following:

  1. DLV03tpl.doc (Original Document)
  2. DLV03tpl_1_Merged.doc (Original Document with merged data)
  3. DLV03tpl_1_Merged.pdf (Merged document converted to PDF)

The problem…
When I take the original document and merge with a single record. It produces a two page document. The second page contains a Numbered List (about mid way down the page). If I merge more than 1 record, for all the subsequent records after the first, their second page’s Numbered List continues the number instead of restarting at 1.
For Example:

1st record: 2nd Page: Numbered List {1, 2, 3, 4}
2nd record: 2nd Page: Number List {5, 6, 7, 8} - Should be {1, 2, 3, 4}
3rd record: 2nd Page: Number List {9, 10, 11, 12} - Should be {1, 2, 3, 4}



Thanks for your request. This is the known issue #6385 in our defect database.
As a workaround, you can try to restart lists in each section. For example see the following code;

// Create dummy datasource
DataTable table = new DataTable();
table.Rows.Add(new object[] { "test", "test", "test", "test" });
table.Rows.Add(new object[] { "test", "test", "test", "test" });
table.Rows.Add(new object[] { "test", "test", "test", "test" });
// Open template
Document doc = new Document(@"Test228\in.doc");
// loop through all section in the docuemnt
foreach (Section sect in doc.Sections)
    List tmpList = null;
    List newList = null;
    // Get collection of paragraps in the section
    NodeCollection paragraphs = sect.GetChildNodes(NodeType.Paragraph, true);
    // loop through all paragraphs
    foreach (Paragraph par in paragraphs)
        if (par.IsListItem)
            if (!par.ListFormat.List.Equals(tmpList))
                // Create new list
                newList = doc.Lists.AddCopy(par.ListFormat.List);
                // Store list in temporary variable
                tmpList = par.ListFormat.List;
            // Restart list.
            par.ListFormat.List = newList;

Best regards.

The issues you have found earlier (filed as WORDSNET-1860) have been fixed in this Aspose.Words for .NET 19.12 update and this Aspose.Words for Java 19.12 update.