Aspose Team,
I am using Aspose.Words version 6.2.0.0. Attached is a zip file containing the following:
DLV03tpl.doc (Original Document)
DLV03tpl_1_Merged.doc (Original Document with merged data)
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.Columns.Add("LTDT");
table.Columns.Add("IVNM");
table.Columns.Add("LTAN");
table.Columns.Add("ADD1");
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");
doc.MailMerge.Execute(table);
// 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;
}
}
}
doc.Save(@"Test228\out.doc");