Class ListElement
An ordered or unordered list. Items may contain any layout elements including nested lists; items are split across pages. In tagged documents the list is tagged as L / LI / Lbl / LBody.
public sealed class ListElement : LayoutElement
- Inheritance
-
ListElement
- Inherited Members
Examples
var list = new ListElement(ListStyle.Decimal) { Font = font };
list.AddItem("First item");
list.AddItem("Second item").Add(new ListElement(ListStyle.Dash).AddItems("Sub-item a", "Sub-item b"));
layout.Add(list);
Constructors
ListElement(ListStyle)
Creates an empty list with the given label style (default Bullet).
public ListElement(ListStyle style = ListStyle.Bullet)
Parameters
styleListStyle
Properties
Color
Color of the labels and of items added as text (default black).
public PdfColor Color { get; set; }
Property Value
Font
Font of the labels and of items added as text.
public PdfFont Font { get; set; }
Property Value
FontSize
Font size in points of the labels and of items added as text (default 10).
public double FontSize { get; set; }
Property Value
ItemSpacing
Vertical space between items in points (default 2).
public double ItemSpacing { get; set; }
Property Value
Items
The items in the order they were added.
public IReadOnlyList<ListItem> Items { get; }
Property Value
LabelFormatter
Custom label text per item number (overrides Style).
public Func<int, string>? LabelFormatter { get; set; }
Property Value
LabelWidth
Width reserved for the labels in points (default 18).
public double LabelWidth { get; set; }
Property Value
StartNumber
Number of the first item for numbered styles (default 1).
public int StartNumber { get; set; }
Property Value
Style
Label style of the items.
public ListStyle Style { get; set; }
Property Value
Methods
AddItem(params LayoutElement[])
Adds an item with the given content.
public ListItem AddItem(params LayoutElement[] content)
Parameters
contentLayoutElement[]
Returns
AddItem(string)
Adds an item with text formatted with the list's font.
public ListItem AddItem(string text)
Parameters
textstring
Returns
AddItems(params string[])
Adds several text items; returns the list (fluent).
public ListElement AddItems(params string[] texts)
Parameters
textsstring[]
Returns
GetLabel(int)
The label text of the item with the given 0-based index.
public string GetLabel(int index)
Parameters
indexint