How to created nested list in doc

Hi, I bought the aspose.word for java and feel happy to use it in my project, but I come cross a problem that needs me to create the nested list (unordered list and ordered list nested together) into the new doc, for example:

I want to create a list in the doc like this :

  1. List item 1

  2. List item 2

. List item 3

. List item 4

  1. List item 5

  2. List item 6

. List item 7

  1. List item 8

I don’t know how to do this properly using aspose.words for java, I also attached a sample doc which contains the sample lists I need to create. could u provide a sample code for handling this issue?

thank you

Hello,
Thank you for your inquiry.
I think what you seek is very well described here in this post: https://forum.aspose.com/t/78352
Please look at it. If you still have any questions please do not hesitate to ask.

HI, thanks for your reply.

but I don’t think this is helpful to my case, cos I need to create a nested list which is unordered list nests ordered list or vice versa, not just the customised list number format. More specific to say, I need the aspose.words can identify the new created ordered/unordered nesting list when I parse the new doc file. could you provide the sample code for creating this nested list( I have put this kind of nested list in the attached sample.doc in the first message)?

If you can provide more detailed answer, I will be very appreciate it .

Thank you for additional information.
Here is a sample code. slightly modified .NET example (here Java version).
Here are two lists. They adjusted the styles list level.
Further, when creating the list, we apply first the first list, and then a second.

License license = new License();
license.SetLicense("Aspose.Words.lic");
Document doc = new Document();
// Create a list based on one of the Microsoft Word list templates.
List list = doc.Lists.Add(ListTemplate.NumberDefault);
// Completely customize one list level.
ListLevel level1 = list.ListLevels[0];
level1.Font.Size = 12;
level1.NumberStyle = NumberStyle.Arabic;
level1.StartAt = 1;
level1.NumberFormat = "\u0000";
level1.TextPosition = 0;
level1.TabPosition = 20;
ListLevel level2 = list.ListLevels[1];
level2.Font.Size = 12;
level2.NumberStyle = NumberStyle.Arabic;
level2.NumberFormat = "\u0001";
level2.TextPosition = 20;
level2.TabPosition = 20;
// Create a list based on one of the Microsoft Word list templates.
List list2 = doc.Lists.Add(ListTemplate.NumberDefault);
// Completely customize yet another list level.
ListLevel levelbullet2 = list2.ListLevels[1];
levelbullet2.Alignment = ListLevelAlignment.Right;
levelbullet2.NumberStyle = NumberStyle.Bullet;
levelbullet2.Font.Size = 12;
levelbullet2.NumberFormat = "\u25CF"; // A bullet list.
levelbullet2.TrailingCharacter = ListTrailingCharacter.Space;
levelbullet2.TabPosition = 20;
levelbullet2.NumberPosition = 40;
// Now add some text that uses the list that we created.
DocumentBuilder builder = new DocumentBuilder(doc);
builder.ListFormat.List = list;
builder.Writeln("The quick brown fox...");
builder.Writeln("The quick brown fox...");
builder.ListFormat.ListIndent();
builder.Writeln("jumped over the lazy dog.");
builder.Writeln("jumped over the lazy dog.");
builder.ListFormat.ListOutdent();
builder.Writeln("The quick brown fox...");
// Here we change list.
builder.ListFormat.List = list2;
builder.ListFormat.ListIndent();
builder.Writeln("jumped over the lazy dog.");
builder.Writeln("jumped over the lazy dog.");
// Here we change list again.
builder.ListFormat.List = list;
builder.ListFormat.ListOutdent();
builder.Writeln("The quick brown fox...");
builder.ListFormat.RemoveNumbers();
doc.Save("X:\\out.doc", SaveFormat.Doc);

If you have difficulty in translating the code from .NET to Java I’ll translate it.