Create list with multiple paragraphs in a list item

Hi,

I am trying to create a list where certain items in a list contain multiple paragraphs. I have attached a screenshot of a list I created manually in word. I want to create this kind of list using the DocumentBuilder.

I have spend several hours on this task, so far without the wanted result. I have tried to stop the list after adding ‘Item 1 - Paragraph 1’, set the LeftIndentation for ‘Item 1 - Paragraph 2’, reset the indentation to 0 after ‘Item 1 - Paragraph 2’ and than resume the list for Item 2. However for some reason the indentation of ‘Item 2’ (and subsequent items) is not correct anymore.

Can you give me an example how to create this list using DocumentBuilder.

Hi

Thanks for your inquiry. I think, in your case it is better to use Line breaks within list item. In this case whole list item will be only one paragraph. For example, see the following code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Start numbering
builder.ListFormat.ApplyNumberDefault();
// Insert first item
builder.Write("This is th efirst line of the first item.");
builder.InsertBreak(BreakType.LineBreak);
builder.Writeln("This is the second and last line of the first item.");
// Insert the second item.
builder.Write("This is the second item");
doc.Save(@"Test001\out.doc");

Hope this helps.
Best regards.

Thanks for your promt answer.

This is my current solution. It works, but is not exactly what I want. The problem with this solution is that there is no ‘SpacingBefore’ and/or ‘SpacingAfter’ for ‘Line1 - Paragraph 2’. In other words: there is no spacing between the paragraphs. I my real reports the actual paragraph text is considerable larger and it looks quite ugly when they are glued together. Beside the esthetics, the readability is also not optimal.

So I am looking for a solution where there is more space between the paragraphs.

Best regards,

Hi

Thank you for additional information. In this case, you can try using code like the following:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Create list.
List list = doc.Lists.Add(ListTemplate.NumberDefault);
// Assign list to the first paragraph.
builder.CurrentParagraph.ListFormat.List = list;
builder.Writeln("This is th efirst line of the first item.");
// Remove numbering of the next paragraph.
builder.CurrentParagraph.ListFormat.RemoveNumbers();
// Insert one more paragraph.
builder.Writeln("This is the second and last line of the first item.");
// Assign the list to the current paragraph again.
builder.CurrentParagraph.ListFormat.List = list;
// Insert the second item.
builder.Write("This is the second item");
doc.Save(@"Test001\out.doc");

Hope this helps.
Best regards.