We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to stop writing bullets and switch to plain paragraphs

I’m creating a bulleted list like this, but how do I tell Builder to stop writing bullets and switch back to ordinary text?


List list = doc.Lists.Add(ListTemplate.BulletDefault);
Paragraph para = builder.CurrentParagraph;
para.ParagraphFormat.SpaceBefore = 0;
para.ListFormat.List = list;
para.ParagraphFormat.FirstLineIndent = -16;
para.ParagraphFormat.LeftIndent = 22;
builder.Writeln(“whatever”);

I’ve tried just calling builder.Writeln() with no argument but it inserts an empty bullet. I can’t seem to identify a method that says “OK, I’m done with bullets now, switch to normal text”.

Don’t you hate that? You give up on finding a solution on your own, then you try something which seems wacky, and it works! Posting here for others in case it helps one day:


// Write an empty line or else the last bullet ends up being a line on its own outside the list
builder.Writeln();
builder.CurrentParagraph.ListFormat.List = null;
builder.CurrentParagraph.ParagraphFormat.FirstLineIndent = 0;
builder.CurrentParagraph.ParagraphFormat.LeftIndent = 0;
builder.Writeln();

Hi Marc,


Thanks for your inquiry. Please see the following code:

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

// Create a numbered list based on one of the Microsoft Word list templates and

// apply it to the current paragraph in the document builder.

builder.ListFormat.List = doc.Lists.Add(ListTemplate.NumberArabicDot);

// There are 9 levels in this list, lets try them all.

for (int i = 0; i < 9; i++)

{

builder.ListFormat.ListLevelNumber = i;

builder.Writeln("Level " + i);

}

// Create a bulleted list based on one of the Microsoft Word list templates

// and apply it to the current paragraph in the document builder.

builder.ListFormat.List = doc.Lists.Add(ListTemplate.BulletDiamonds);

// There are 9 levels in this list, lets try them all.

for (int i = 0; i < 9; i++)

{

builder.ListFormat.ListLevelNumber = i;

builder.Writeln("Level " + i);

}

// This is a way to stop list formatting.

builder.ListFormat.List = null;

builder.Document.Save(MyDir + "Lists.SpecifyListLevel Out.doc");


Hope, this helps.

Best regards,

Thanks. That’s simpler than my kludge.


Edit: I still need to do this to return the indentation back to where it was (probably because I’m setting them to be different than the default)

builder.ParagraphFormat.FirstLineIndent = 0;
builder.ParagraphFormat.LeftIndent = 0;

Hi Marc,


It is great you were able to find what you were looking for. Please let us know any time you have any further queries.

Best regards,