Aspose Limitation with respect to List Numbering

I’m trying to generate list using Aspose Words, After 2046 list numbering disappears. Please find code and output

public static void testlist()
{
    Document doc = new Document();
    Section currentSection = new Section(doc);

    doc.AppendChild(currentSection);
    Body body = new Body(doc);
    currentSection.AppendChild(body);
    currentSection.PageSetup.SectionStart = SectionStart.Continuous;
    for (int i = 0; i < 3000; i++)
    {
        Console.WriteLine(i);
        listcreation(doc, body, i);
    }
    doc.Save("ListOutput.docx");
}

public static void listcreation(Document doc, Body body, int lvl)
{
    Paragraph currentParagraph = new Paragraph(doc);
    Run rn = new Run(doc, "A very big ");
    ListLevel listLevel = null;
    currentParagraph.ListFormat.List = doc.Lists.Add(ListTemplate.NumberDefault);
    currentParagraph.ParagraphFormat.SpaceBefore = 6;
    listLevel = currentParagraph.ListFormat.List.ListLevels[0];
    listLevel.Font.Name = "Arial";
    listLevel.Font.Size = 10;
    listLevel.LinkedStyle = currentParagraph.ParagraphFormat.Style;
    listLevel.LinkedStyle.ParagraphFormat.SpaceBefore = 6;
    listLevel.StartAt = lvl;
    currentParagraph.ParagraphFormat.LeftIndent = 36;
    currentParagraph.AppendChild(rn);
    body.AppendChild(currentParagraph);
}

Hi Manikandan,

Thanks for your inquiry. We like to share with you that the count of list definitions per document is limited. MS Word itself has limited count of lists and stop displaying it after limit is exceeded.

For DOCX format, there is no limitation specified. It seems that MS Word has limited slots for list definitions and stops adding new lists after list count reaches 2046 items.

In your case, we suggest you please use one list to format for all list items as shown in following code example. Hope this helps you.

Document doc = new Document();
Section currentSection = new Section(doc);
doc.AppendChild(currentSection);
Body body = new Body(doc);
currentSection.AppendChild(body);
currentSection.PageSetup.SectionStart = SectionStart.Continuous;
List list = doc.Lists.Add(ListTemplate.NumberDefault);
for (int i = 0; i < 3000; i++)
{
    Console.WriteLine(i);
    listcreation(doc, body, i, list);
}
doc.Save(MyDir + "Out.docx");
public static void listcreation(Document doc, Body body, int lvl, List list)
{
    Paragraph currentParagraph = new Paragraph(doc);
    Run rn = new Run(doc, "A very big ");
    ListLevel listLevel = null;
    currentParagraph.ListFormat.List = list;
    currentParagraph.ParagraphFormat.SpaceBefore = 6;
    listLevel = currentParagraph.ListFormat.List.ListLevels[0];
    listLevel.Font.Name = "Arial";
    listLevel.Font.Size = 10;
    listLevel.LinkedStyle = currentParagraph.ParagraphFormat.Style;
    listLevel.LinkedStyle.ParagraphFormat.SpaceBefore = 6;
    listLevel.StartAt = lvl;
    currentParagraph.ParagraphFormat.LeftIndent = 36;
    currentParagraph.AppendChild(rn);
    body.AppendChild(currentParagraph);
}