GemBox.Document is a .NET component that enables you to read, write, edit, convert, and print document files from your .NET applications using one simple API.

Lists

GemBox.Document supports all common lists: ordered and unordered with various bullet styles and numbering formats.

Following example demonstrates how to create list (numbering) styles and apply them to paragraphs with different list (indentation) levels.

Screenshot
Lists Screenshot

See the full code below, use Run Example to execute.

using System;
using System.Globalization;
using GemBox.Document;

class Sample
{
    [STAThread]
    static void Main(string[] args)
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        DocumentModel document = new DocumentModel();

        // First create list style.
        ListStyle numberList = new ListStyle(ListTemplateType.NumberWithDot);

        // Then set Paragraph.ListFormat.Style and ParagraphListFormat.ListLevelNumber.
        Paragraph para1 = new Paragraph(document, "First item.");
        para1.ListFormat.Style = numberList;
        para1.ParagraphFormat.NoSpaceBetweenParagraphsOfSameStyle = true;

        Paragraph para2 = new Paragraph(document, "Second item.");
        para2.ListFormat.Style = numberList;
        para2.ParagraphFormat.NoSpaceBetweenParagraphsOfSameStyle = true;

        Paragraph para2a = new Paragraph(document, "Sub item 2a.");
        para2a.ListFormat.Style = numberList;
        para2a.ListFormat.ListLevelNumber++;
        para2a.ParagraphFormat.NoSpaceBetweenParagraphsOfSameStyle = true;

        Paragraph para2b = new Paragraph(document, "Sub item 2b.");
        para2b.ListFormat.Style = numberList;
        para2b.ListFormat.ListLevelNumber++;
        para2b.ParagraphFormat.NoSpaceBetweenParagraphsOfSameStyle = true;

        Paragraph para3 = new Paragraph(document, "Third item.");
        para3.ListFormat.Style = numberList;
        para3.ParagraphFormat.NoSpaceBetweenParagraphsOfSameStyle = true;

        Section section = new Section(document, para1, para2, para2a, para2b, para3);
        document.Sections.Add(section);

        section.Blocks.Add(new Paragraph(document));

        // Create list style.
        ListStyle bulletList = new ListStyle(ListTemplateType.Bullet);

        // Use it.
        section.Blocks.Add(
            new Paragraph(document, "First item.")
            {
                ParagraphFormat = new ParagraphFormat() { NoSpaceBetweenParagraphsOfSameStyle = true },
                ListFormat = new ListFormat() { Style = bulletList }
            });

        section.Blocks.Add(
            new Paragraph(document, "Second item.")
            {
                ParagraphFormat = new ParagraphFormat() { NoSpaceBetweenParagraphsOfSameStyle = true },
                ListFormat = new ListFormat() { Style = bulletList }
            });

        section.Blocks.Add(
            new Paragraph(document, "Sub item 2a.")
            {
                ParagraphFormat = new ParagraphFormat() { NoSpaceBetweenParagraphsOfSameStyle = true },
                ListFormat = new ListFormat() { Style = bulletList, ListLevelNumber = 1 }
            });

        section.Blocks.Add(
            new Paragraph(document, "Item below sub item 2a.")
            {
                ParagraphFormat = new ParagraphFormat() { NoSpaceBetweenParagraphsOfSameStyle = true },
                ListFormat = new ListFormat() { Style = bulletList, ListLevelNumber = 2 }
            });

        section.Blocks.Add(
            new Paragraph(document, "Third item.")
            {
                ParagraphFormat = new ParagraphFormat() { NoSpaceBetweenParagraphsOfSameStyle = true },
                ListFormat = new ListFormat() { Style = bulletList }
            });

        document.Save("Lists.docx");
    }
}
Imports System
Imports System.Globalization
Imports GemBox.Document

Module Samples

    Sub Main()

        ' If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        Dim document As DocumentModel = New DocumentModel

        ' First create list style.
        Dim numberList As New ListStyle(ListTemplateType.NumberWithDot)

        ' Then set Paragraph.ListFormat.Style and ParagraphListFormat.ListLevelNumber.
        Dim para1 As New Paragraph(document, "First item.")
        para1.ListFormat.Style = numberList
        para1.ParagraphFormat.NoSpaceBetweenParagraphsOfSameStyle = True

        Dim para2 As New Paragraph(document, "Second item.")
        para2.ListFormat.Style = numberList
        para2.ParagraphFormat.NoSpaceBetweenParagraphsOfSameStyle = True

        Dim para2a As New Paragraph(document, "Sub item 2a.")
        para2a.ListFormat.Style = numberList
        para2a.ListFormat.ListLevelNumber += 1
        para2a.ParagraphFormat.NoSpaceBetweenParagraphsOfSameStyle = True

        Dim para2b As New Paragraph(document, "Sub item 2b.")
        para2b.ListFormat.Style = numberList
        para2b.ListFormat.ListLevelNumber += 1
        para2b.ParagraphFormat.NoSpaceBetweenParagraphsOfSameStyle = True

        Dim para3 As New Paragraph(document, "Third item.")
        para3.ListFormat.Style = numberList
        para3.ParagraphFormat.NoSpaceBetweenParagraphsOfSameStyle = True

        Dim section As New Section(document, para1, para2, para2a, para2b, para3)
        document.Sections.Add(section)

        section.Blocks.Add(New Paragraph(document))

        ' Create list style.
        Dim bulletList As New ListStyle(ListTemplateType.Bullet)

        ' Use it.
        section.Blocks.Add(
            New Paragraph(document, "First item.") With {
                .ParagraphFormat = New ParagraphFormat() With {
                    .NoSpaceBetweenParagraphsOfSameStyle = True
                },
                .ListFormat = New ListFormat() With {
                    .Style = bulletList
                }})

        section.Blocks.Add(
            New Paragraph(document, "Second item.") With {
                .ParagraphFormat = New ParagraphFormat() With {
                    .NoSpaceBetweenParagraphsOfSameStyle = True
                },
                .ListFormat = New ListFormat() With {
                    .Style = bulletList
                }})

        section.Blocks.Add(
            New Paragraph(document, "Sub item 2a.") With {
                .ParagraphFormat = New ParagraphFormat() With {
                    .NoSpaceBetweenParagraphsOfSameStyle = True
                },
                .ListFormat = New ListFormat() With {
                    .Style = bulletList,
                    .ListLevelNumber = 1
                }})

        section.Blocks.Add(
            New Paragraph(document, "Item below sub item 2a.") With {
                .ParagraphFormat = New ParagraphFormat() With {
                    .NoSpaceBetweenParagraphsOfSameStyle = True
                },
                .ListFormat = New ListFormat() With {
                    .Style = bulletList,
                    .ListLevelNumber = 2
                }})

        section.Blocks.Add(
            New Paragraph(document, "Third item.") With {
                .ParagraphFormat = New ParagraphFormat() With {
                    .NoSpaceBetweenParagraphsOfSameStyle = True
                },
                .ListFormat = New ListFormat() With {
                    .Style = bulletList
                }})

        document.Save("Lists.docx")

    End Sub

End Module

Check next sample.