Using ASPOSE.Words how can I change the indent behavior of ListItems

I am working on a Document generation, we were using SSRS for, but due to the requirements we are looking into the ASPOSE.Words for .Net. In the little bit of time working with the package I’ve gotten most of my document setup and ready for dynamic generation. The issue is my requirements force me to mimic an existing format which uses Number List like 1, 1.1, 2, 2.1 and so on, as well these numbered lists do not use indent at any level.

e.x:
(‘normal’ list format)
-1
–1.1
–1.2
-2
–2.1
…and so on

The format I need is

1
1.1
1.2
2
2.1
…and so on

Using the ASPOSE.Words .Net package how can I accomplish this?

After the formatting of the indent is solved, my next question will be how do I set the numbers to follow the pattern from above?

I’ve tried checking the google, and the ASPOSE Forms but to no avail.

Any help or guidance would be much helpful!

Thanks,
Ron

Hi Ron,

Thanks
for your inquiry. Please use ListLevel.NumberFormat property to get or set the number format for the list level.

Among normal text characters, the string can contain placeholder characters \x0000 to \x0008 representing the numbers from the corresponding list levels.

For example, the string “\x0000.\x0001)” will generate a list label that looks something like “1.5)”. The number “1” is the current number from the 1st list level, the number “5” is the current number from the 2nd list level.

Use ListLevel.NumberStyle property to get or set the number style for this list level. Please check the following code example for your kind reference. Hope this helps you.

Document doc = new Document(MyDir + "Test40.docx");
List list = doc.Lists[0];
list.ListLevels[0].NumberStyle = NumberStyle.Arabic;
list.ListLevels[0].NumberFormat = "\x0000";
list.ListLevels[1].NumberStyle = NumberStyle.Arabic;
list.ListLevels[1].NumberFormat = "\x0000.\x0001";
doc.Save(MyDir + @"out.docx");
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.ListFormat.List = doc.Lists.Add(ListTemplate.NumberDefault);
builder.ListFormat.ListLevel.Font.Bold = true;
builder.ListFormat.ListLevel.Font.Color = Color.Red;
builder.Writeln("Main Section1");
builder.ListFormat.ListIndent();
builder.ListFormat.ListLevel.Font.Italic = true;
builder.ListFormat.ListLevel.Font.Color = Color.Green;
builder.ListFormat.ListLevel.NumberStyle = NumberStyle.Arabic;
builder.ListFormat.ListLevel.NumberFormat = "\x0000.\x0001";
builder.Writeln("Sub Section1.1 ");
builder.ListFormat.ListIndent();
builder.ListFormat.ListLevel.Font.Underline = Underline.Dash;
builder.ListFormat.ListLevel.Font.Color = Color.Blue;
builder.ListFormat.ListLevel.NumberStyle = NumberStyle.Arabic;
builder.ListFormat.ListLevel.NumberFormat = "\x0000.\x0001.\x0002";
builder.Writeln("Sub Section 1.1.1");
builder.ListFormat.ListOutdent();
builder.Writeln("Sub Section 1.2 ");
builder.ListFormat.ListOutdent();
builder.Writeln("Main Section2");
builder.ListFormat.ListIndent();
builder.Writeln("Sub Section2.1");
builder.ListFormat.RemoveNumbers();
doc.Save(MyDir + @"out.docx");

Thank you Tahir for your reply, I see now how to set the numbering for my lists now. I do still have an outstanding question on how to manage the indent formatting. As described in my question I need to remove all indent formatting from my lists. How is this goal achievable using the ASPOSE.Words for .NET?

Thanks,
Ron

Hi Ron,

Thanks
for your inquiry. Please use ParagraphFormat.LeftIndent and ParagraphFormat.RightIndent properties to get or set the value (in points) that represents the left and right indent for paragraph.

Please read following documentation for your kind reference.
https://docs.aspose.com/words/net/applying-formatting/