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

Free Support Forum - aspose.com

List not getting generated after 2047

Hi Aspose Team

I had a scenario where I had to create around 3000 custom list objects in the word document. I found out that after 2052 lists, the list are not getting generated and only plain paragraphs are coming.
May I know why is it happening. Is this Microsoft word limitation or Aspose Issue?
Attaching the word document and the respective POC code for your reference.
NumberingTest.zip (23.3 KB)

@gayudearest,

Thanks for your inquiry. Please note 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 all list items. Please add following line of code outside the for loop. Hope this helps you.

Aspose.Words.Lists.List list = doc.Lists.Add(ListTemplate.NumberDefault);

Aspose.Words.Document doc = new Aspose.Words.Document();
Section wordSection = new Section(doc);
doc.Sections.Add(wordSection);
wordSection.PageSetup.TopMargin = 42.0f;
wordSection.PageSetup.LeftMargin = 50.0f;
wordSection.PageSetup.BottomMargin = 42.0f;
wordSection.PageSetup.RightMargin = 50.0f;
wordSection.PageSetup.FooterDistance = 20;
wordSection.PageSetup.HeaderDistance = 20;
wordSection.PageSetup.SectionStart = SectionStart.Continuous;
wordSection.PageSetup.PageNumberStyle = NumberStyle.Arabic;
wordSection.AppendChild(new Body(doc));

Aspose.Words.Lists.List list = doc.Lists.Add(ListTemplate.NumberDefault);

for (int i = 0; i < 2055; i++)
{
    ListLevel listLevel = list.ListLevels[0];
    listLevel.Font.Size = 10;
    listLevel.NumberFormat = "%1";
    listLevel.NumberPosition = 0;
    listLevel.TabPosition = 0;
    listLevel.TextPosition = 0;
    listLevel.NumberStyle = NumberStyle.Arabic;

    Paragraph paraGraph = new Paragraph(doc);
    Run run = new Run(doc, " List No." + (i + 1) + "......");
    paraGraph.AppendChild(run);
    paraGraph.ListFormat.List = list;
    paraGraph.ListFormat.ListLevelNumber = 0;
    paraGraph.ParagraphFormat.SpaceBefore = 12;
    wordSection.Body.AppendChild(paraGraph);
    paraGraph = new Paragraph(doc);
    run = new Run(doc, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eleifend metus sed mauris bibendum, eu molestie felis molestie. Sed in nibh eget nisl ultrices viverra at non quam. Integer at mattis mi, non sollicitudin nisi. Aliquam eget quam vehicula, sollicitudin velit eu, mattis nunc. Integer eu sem neque. Aenean lacinia nibh finibus purus imperdiet, nec tempus neque semper. Vivamus at nulla luctus, rutrum leo blandit, imperdiet justo. Phasellus eget magna sagittis, lobortis odio nec, ultrices arcu. Nam cursus nunc ac dictum fringilla. Aenean ac vestibulum ex. In ac tincidunt lectus. Vestibulum pharetra odio velit, et placerat ante lobortis nec. Aenean et dolor sem. Phasellus semper massa vel nulla blandit commodo. Fusce velit dolor, ullamcorper nec orci ut, tincidunt finibus est. Mauris tempus leo at magna euismod porttitor. ");
    paraGraph.AppendChild(run);
    wordSection.Body.AppendChild(paraGraph);
}

Thank you for your reply Tahir. But the problem is that each list has a custom label defined. SO I cannot create a single list for all the list items.
Now that I know the limitation of word document. I will try rendering the list as normal text and paragraphs instead of list.

@gayudearest,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.