Aspose.word break out of a list

Howdy. I am having trouble breaking from a list in code. In word, if im at the end of the list and I hit enter twice, I get out of it. In aspose, ive tried inserting two Paragraph breaks, but it just adds to the list.
So if I have the below, using aspose, how do I add a blank paragraph below this without making it part of the list?

  1. Test
  2. test

@dmerkle1 You can use ListFormat.RemoveNumbers() method. For example see the following code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Start list.
builder.ListFormat.ApplyNumberDefault();
// Add some items
builder.Writeln("item 1");
builder.Writeln("item 2");
builder.Writeln("item 3");
// Stop numbering
builder.ListFormat.RemoveNumbers();
builder.Writeln("This is not a list item.");

doc.Save(@"C:\Temp\out.docx");

out.docx (7.8 KB)

Hi @alexey.noskov ,
Thanks for the quick reply. The issue I’m having is I’m loading a document that has a list at the bottom, when I moveToDocumentEnd() and then RemoveNumbers() and then InsertBreak(ParagraphBreak), the last list item has its number removed.

@dmerkle1 You should first insert a paragraph break and then remove the numbers:

builder.Writeln();
builder.ListFormat.RemoveNumbers();
1 Like