Free Support Forum - aspose.com

Customize Bullets Character

Hi,

I want to customize the bullets character and choose special one that not supported in the ListTemplate Enum.

Example:

- Line 1

- Line 2

- Line 3

here the dash character (-) is not supported in the ListTemplate Enum.

can you help?

The bullet character is set in ListLevel.NumberFormat property. There is an example for using this property in the API Reference.

The ListLevel.NumberFormat property is useful when I use the builder.writeln method, but it is not useful with builder.InsertHtml.

I have an HTML text that may contain a list inside, I cant control the bullet character in this case, is there anyway to cotrol the chracter and change it from BulletDisk to Dash?

Yes, you can insert HTML and then iterate through inserted text and change the bullets of the list items to dash. Here is an example:

// Mark the paragraph after which the HTML will be inserted.

Paragraph startingParagraph = builder.CurrentParagraph;

builder.InsertHtml(@"

List:

  • Item1
  • Item2
");

Paragraph paragraph = builder.CurrentParagraph;

// Iterate thorugh all paragraphs inserted by DocumentBuilder and change the bullet of the list items to dash.

while (paragraph != startingParagraph)

{

if (paragraph.IsListItem)

paragraph.ListFormat.ListLevel.NumberFormat = "-";

paragraph = (Paragraph)paragraph.PreviousSibling;

}

Yes, it works now, thank you sir.