Free Support Forum -

Restart or Continue Numbered Lists at Each Section in Word Document after Mail Merge using Java

Hi Aspose team!

I’m having an issue in a numbered list which breaks after mail merge.

DataTable table = new DataTable("MailMerge");

List<String> values = new ArrayList<String>();

for (TokenValue tokenValue : input.getTokenList()) {


This code just changes the tokens for an input document. But if this one has a numbered list, it restarts in some point.

I’ve reviewed this case:

Here i attach the input and output document (in zip file) and you will see the differences between number 5 and 6. In Microsoft Word in the output document, the number 6 is number 1, but it works ok for Google Docs or Apple Pages. The problem here is when we save it as PDF, it restart the list after number 5. (62.1 KB)

I hope you can help me.

Best and Kind Regards.


MS Word 2019 also produces a similar output when saving to DOCX format after performing mail merge (see mail merge by ms word (30.2 KB)). And Aspose.Words for Java mimics the behavior of MS Word in this case. However, for the sake of any corrections in Aspose.Words’ API, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-22095. We will further look into the details of this problem and will keep you updated on the status of linked issue. We apologize for any inconvenience.


Regarding WORDSNET-22095, we have completed the analysis of this issue and concluded to close this issue with “not a bug” status. But, we will add MailMerge.RestartListsAtEachSection property to control list numbering restart which is exactly for this purpose. We will introduce the MailMerge.RestartListsAtEachSection property in Aspose.Words’ 21.5 version to control whether or not list numbering is restarted at each section when mail merge is performed. It is true by default to mimic MS Word’s behavior, but can be set to false if you want continuous numbering.

MS Word applies restartNumberingAfterBreak attribute to each list in document during mail merge and you may use following code snippet to retain original list numbering:

Document doc = new Document("C:\\temp\\Archive\\Generic_NDA_-_template.docx");

Map<com.aspose.words.List, Boolean> lists = new HashMap<com.aspose.words.List, Boolean>();
for (com.aspose.words.List list : (Iterable<com.aspose.words.List>) doc.getLists())
    lists.put(list, list.isRestartAtEachSection());

        new String[]{
        new Object[]{
                "Luis Alfredo Porras",

for (Map.Entry<com.aspose.words.List, Boolean> entry : lists.entrySet()) {
    com.aspose.words.List list = entry.getKey();