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
-
BII EXCEPTIONS
Testtesttest test test test
-
qqq1
-
ddd1
-
ffff1
-
two1
-
three1
Hello
BII EXCEPTIONS
Testtesttest test test test
-
qqq2
-
ddd2
-
ffff2
-
two2
-
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:
-
first main list item
-
First Para Line
Second Para Line
- one
- two
First Para Line
Second Para Line
- 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
- first main list item
First Para Line
Second Para Line
- one
- two
First Para Line
Second Para Line
A. one
B. two
i. nest 3 a
ii. nest 3 b
- 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);