List
The List class helps you create a list of numbered paragraphs. You can use lists by adding them to the RadFixedDocumentEditor Lists collection or by creating List class instances and setting the list bullets to some Block instances.
Bulleted list output in RadPdfProcessing

The following sections present the list-related API in RadPdfProcessing:
Creating List from ListTemplateType
Each List contains a ListLevelCollection where the presentation of each list level is defined by a ListLevel class instance. For the most common cases you do not need to define each separate list level. Instead, you can use the ListTemplateType enumeration to create a list with one of the predefined list templates.
The following snippet shows how to create a list with the NumberedParentheses template.
Create a numbered parentheses list template
List numberedParenthesesList = new List(ListTemplateType.NumberedParentheses);
The following image shows the available list template types and their appearance:
Available list template types and their appearance

In .NET Standard due to font limitations, the
BulletDefaultlist requires a Wingdings font be provided so its bullets are rendered properly. You can read how to handle these restrictions in the Fonts and FontsProvider articles.
Creating Custom ListLevel
When you need to create a custom List, define the presentation of each list level. The appearance of the list level is defined with the properties of the ListLevel class. The following list level properties are available in RadPdfProcessing:
-
StartIndex: Specifies the index from which the list items numbering starts. The default value of this property is 1. -
RestartAfterLevel: Specifies the index of the level, which restarts the current level numbering. The default value is negative, which means that all previous levels restart the current level numbering. If this property has a non-negative value, all previous levels that have a level index less than or equal to theRestartAfterLevelvalue restart the current level numbering. -
ParagraphProperties: Specifies the paragraph properties of the paragraphs from this list level. -
CharacterProperties: Specifies the character properties of the bullet element on this list level. -
BulletNumberingFormat: Specifies how the bullet element is formatted on this list level. -
IndentAfterBullet: Specifies the amount of indent after the bullet element.
The following snippet shows how to create an empty list and add two custom list levels to its ListLevelsCollection. Level 0 has a bullet which displays its current numbering as a two-digit number with a leading zero. Level 1 displays a checkbox as a bullet symbol for all corresponding list items. Additionally, each level defines custom values for the LeftIndent, ForegroundColor, and IndentAfterBullet properties.
Create custom list levels
List bulletList = new List();
ListLevel levelZero = bulletList.Levels.AddListLevel();
levelZero.ParagraphProperties.LeftIndent = 30;
levelZero.CharacterProperties.ForegroundColor = new RgbColor(100, 100, 100);
levelZero.IndentAfterBullet = 5;
levelZero.BulletNumberingFormat =
new TextBulletNumberingFormat((indexer) => string.Format("{0:D2}.", indexer.GetCurrentIndex(0)));
ListLevel levelOne = bulletList.Levels.AddListLevel();
levelOne.ParagraphProperties.LeftIndent = 60;
levelOne.CharacterProperties.ForegroundColor = new RgbColor(100, 100, 100);
levelOne.IndentAfterBullet = 10;
levelOne.BulletNumberingFormat = new TextBulletNumberingFormat((indexer) => "☑");
The following image shows how the custom list levels look when used.
Custom list levels with two-digit numbering and checkbox bullets

Creating Custom Bullet
When you create a custom list level, you need to specify how the bullet numbering is formatted. With RadPdfProcessing, by implementing IBulletNumberingFormat you can choose what PositionContentElement to use for each bullet appearance. This way, knowing the current indexes of all list levels, you can create bullets with text, geometry, or image.
If you need a text bullet, use the TextBulletNumberingFormat class. This class implements IBulletNumberingFormat. When you initialize an instance of this class, its constructor requires a function that returns the string representation of the bullet.
The following code snippet shows how to create the bullets of a numbered hierarchical list using the TextBulletNumberingFormat class:
Create a custom text numbering bullet
List list = new List();
for (int i = 0; i < 3; i++)
{
ListLevel level = list.Levels.AddListLevel();
level.ParagraphProperties.LeftIndent = (i + 1) * 20;
level.IndentAfterBullet = 10;
int currentLevelIndex = i;
level.BulletNumberingFormat = new TextBulletNumberingFormat((indexer) =>
{
StringBuilder builder = new StringBuilder();
for (int levelIndex = 0; levelIndex <= currentLevelIndex; levelIndex++)
{
builder.AppendFormat("{0}.", indexer.GetCurrentIndex(levelIndex));
}
return builder.ToString();
});
}
When using this list, its bullets look as shown in the following image.
Custom hierarchical numbered list bullets

Using Lists with RadFixedDocumentEditor
To use lists with RadFixedDocumentEditor, first add them to the editor ListCollection. Each time you add a list item, set the ListId and ListLevel values in the editor Paragraph properties and call the InsertParagraph() method.
The following snippet shows how to create a list with RadFixedDocumentEditor and insert one item for each list level. The appearance of the list comes from the values in the predefined ListTemplateType enumeration.
Use lists with RadFixedDocumentEditor
RadFixedDocument document = new RadFixedDocument();
using (RadFixedDocumentEditor editor = new RadFixedDocumentEditor(document))
{
List numlist = editor.Lists.AddList(ListTemplateType.NumberedDefault);
editor.ParagraphProperties.ListId = list.Id;
for (int listLevel = 0; listLevel < list.Levels.Count; listLevel++)
{
editor.ParagraphProperties.ListLevel = listLevel;
editor.InsertParagraph();
editor.InsertRun(string.Format("List level {0}", listLevel));
}
}
The resulting document looks like the following image.
List created with RadFixedDocumentEditor

Using Lists with Block Class
As the Block class has Bullet and IndentAfterBullet properties, you can set a custom bullet to any Block instance. However, if you want to get an automatically formatted bullet corresponding to some List class instance, use the SetBullet(List list, int listLevel) method. This way you can set the bullet-related properties so that the bullet displays the correct list numbering and formatting.
The following snippet shows how to create a List with the BulletDefault template and set the bullet of the first list level to a Block:
Use lists with the Block class
List defaultBulletlist = new List(ListTemplateType.BulletDefault);
Block block = new Block();
block.SetBullet(defaultBulletlist, 0);
block.InsertText("Sample block text.");
The list style is applied for the whole Block element. To generate a list consisting of multiple paragraphs in different list items, use the same count of Block instances as the number of different list items.
The following image demonstrates how the block looks when exported.
Block with BulletDefault list style applied
