Numbering restarts with Mail-Merge after Section Break

Dear Aspose-Team,

when I convert a Word-Document (please find attached) to PDF using Aspose.Words, the numbering of the headlines start at 1 again after a Section Break.

This happens only if I perform a Mail-Merge on the document.
How can I ensure that the numbering continues?
I found similiar issues in the forum, but didn’t manage to solve my issue using the provided workarounds.

Code-Snippet:

    import com.aspose.words.Document;
    import com.aspose.words.PdfSaveOptions;
    import com.aspose.words.SaveOptions;

    import java.util.UUID;

    public class SectionBreakWithNumbering {

        public static void main(String[] args) throws Exception {

            Document doc = new Document(SectionBreakWithNumbering.class.getResourceAsStream("/SectionBreakWithNumbering.docx"));
            doc.getMailMerge().execute(new String[0], new String[0]);
            SaveOptions saveOptions = new PdfSaveOptions();
            final String fileName = UUID.randomUUID() + ".pdf";
            System.out.println(fileName);
            doc.save(fileName, saveOptions);
        }
    }

SectionBreakWithNumbering.zip (10.6 KB)

@orgavision

We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-22032. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@orgavision

Please use the following code example to get the desired output. Hope this helps you.

    Document doc = new Document(MyDir + "SectionBreakWithNumbering.docx");

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

    doc.getMailMerge().execute(new String[0], new String[0]);

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

    doc.save(MyDir + "21.3.pdf");

Thanks @tahir.manzoor,

I could successfully implement the suggested workaround.
Is there any plan to fix this in a future version?

@orgavision

Yes, we will add new feature for your requirement in Aspose.Words. We will inform you via this forum thread once there is an update available on it.

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