Table of Contents

Class ListElement

Namespace
MiPdf.Layout
Assembly
MiPdf.dll

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

style ListStyle

Properties

Color

Color of the labels and of items added as text (default black).

public PdfColor Color { get; set; }

Property Value

PdfColor

Font

Font of the labels and of items added as text.

public PdfFont Font { get; set; }

Property Value

PdfFont

FontSize

Font size in points of the labels and of items added as text (default 10).

public double FontSize { get; set; }

Property Value

double

ItemSpacing

Vertical space between items in points (default 2).

public double ItemSpacing { get; set; }

Property Value

double

Items

The items in the order they were added.

public IReadOnlyList<ListItem> Items { get; }

Property Value

IReadOnlyList<ListItem>

LabelFormatter

Custom label text per item number (overrides Style).

public Func<int, string>? LabelFormatter { get; set; }

Property Value

Func<int, string>

LabelWidth

Width reserved for the labels in points (default 18).

public double LabelWidth { get; set; }

Property Value

double

StartNumber

Number of the first item for numbered styles (default 1).

public int StartNumber { get; set; }

Property Value

int

Style

Label style of the items.

public ListStyle Style { get; set; }

Property Value

ListStyle

Methods

AddItem(params LayoutElement[])

Adds an item with the given content.

public ListItem AddItem(params LayoutElement[] content)

Parameters

content LayoutElement[]

Returns

ListItem

AddItem(string)

Adds an item with text formatted with the list's font.

public ListItem AddItem(string text)

Parameters

text string

Returns

ListItem

AddItems(params string[])

Adds several text items; returns the list (fluent).

public ListElement AddItems(params string[] texts)

Parameters

texts string[]

Returns

ListElement

GetLabel(int)

The label text of the item with the given 0-based index.

public string GetLabel(int index)

Parameters

index int

Returns

string