Nested Sublists and embedded Paragraphs

Is it possible to have a list as follows? It’s an outer list whose items in this case are a paragraph, another list with nested sublist, then another paragraph and similar list with sublist?

I am able to achieve this with list levels and writing the paragraphs with escaped linefeed char codes, but once i turn off numbers on the first inner list, the paragraph leftident jumps to the left. If i try to set the left indent, it ruins it for any list after that.

Thanks in advance

  1. BII EXCEPTIONS
    Testtesttest test test test

  2. qqq1

  3. ddd1

  4. ffff1

  5. two1

  6. three1

Hello
BII EXCEPTIONS
Testtesttest test test test

  1. qqq2

  2. ddd2

  3. ffff2

  4. two2

  5. three2

BTW, this is my code and the last set of paragraphs don’t nest nicely

Document doc = new Document();
List list = doc.Lists.Add(ListTemplate.NumberDefault);
ListLevel level1 = list.ListLevels[0];
level1.Font.Size = 12;
level1.NumberStyle = NumberStyle.Arabic;
DocumentBuilder builder = new DocumentBuilder(doc);
builder.ListFormat.List = list;
builder.Writeln("first main list item");
// builder.ListFormat.RemoveNumbers();
builder.Write(" \vFirst Para Line\v \vSecond Para Line\v ");
builder.Writeln("");
builder.ListFormat.ListIndent();
builder.Writeln("one");
builder.Writeln("two");
builder.ListFormat.ListOutdent();
builder.ListFormat.RemoveNumbers();
builder.Write(" \vFirst Para Line\v \vSecond Para Line\v ");
builder.Writeln("");
//double li = builder.ParagraphFormat.LeftIndent;
builder.ListFormat.RemoveNumbers();
// builder.ParagraphFormat.LeftIndent = li;
builder.ListFormat.List = list;
builder.Writeln("next main list item");
doc.Save(@"C:\out2.doc", SaveFormat.Doc);

it ends up looking like this:

  1. first main list item

  2. First Para Line

    Second Para Line

    1. one
    2. two

First Para Line

Second Para Line

  1. next main list item

Sorry to keep posting on this, but is it possible with Aspose to do something like this? I can’t find a way

  1. first main list item

First Para Line

Second Para Line

  1. one
  2. two

First Para Line

Second Para Line

A. one

B. two

i. nest 3 a

ii. nest 3 b

  1. next main list item

Hi Bruno,

Thanks for your inquiry.
Please use the following code example to achieve your requirements. Hope this helps you. Please let us know if you have any more queries.

Document doc = new Document();
List list = doc.Lists.Add(ListTemplate.NumberDefault);
ListLevel level1 = list.ListLevels[0];
level1.Font.Size = 12;
level1.NumberStyle = NumberStyle.Arabic;
List list2 = doc.Lists.Add(ListTemplate.NumberUppercaseLetterDot);
DocumentBuilder builder = new DocumentBuilder(doc);
builder.ListFormat.List = list;
double li = builder.ParagraphFormat.LeftIndent;
builder.Write("first main list item");
builder.InsertBreak(BreakType.LineBreak);
builder.Write("First Para Line");
builder.InsertBreak(BreakType.LineBreak);
builder.Write("Second Para Line");
builder.Writeln("");
builder.ListFormat.ListIndent();
builder.Writeln("one");
builder.Writeln("two");
builder.ListFormat.ListOutdent();
builder.ListFormat.RemoveNumbers();
builder.ParagraphFormat.LeftIndent = li;
builder.Write("First Para Line");
builder.InsertBreak(BreakType.LineBreak);
builder.Write("Second Para Line");
builder.Writeln("");
builder.ListFormat.RemoveNumbers();
builder.ListFormat.List = list2;
builder.ListFormat.ListIndent();
builder.Writeln("one");
builder.Writeln("two");
builder.ListFormat.ListIndent();
builder.Writeln("nest 3a");
builder.Writeln("nest 3b");
builder.ListFormat.ListOutdent();
builder.ListFormat.RemoveNumbers();
builder.ListFormat.List = list;
builder.Writeln("next main list item");
builder.ListFormat.RemoveNumbers();
doc.Save(MyDir + "Out.docx", SaveFormat.Docx);