Click or drag to resize

ListLevelFormat Class

Represents formatting definition which specifies the appearance and behavior of a list level.
Inheritance Hierarchy
SystemObject
  SautinSoft.DocumentFormat
    SautinSoft.DocumentListLevelFormat

Namespace: SautinSoft.Document
Assembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2024.11.20
Syntax
public sealed class ListLevelFormat : Format

The ListLevelFormat type exposes the following members.

Properties
 NameDescription
Public propertyAlignment Gets or sets the justification of the actual number of the list item.
Public propertyCharacterFormat Gets or sets character formatting used for the list label.
Public propertyIsLegal When true, the level turns all inherited numbers to Arabic, false if it preserves their number style.
Public propertyIsOld When true, the level was converted from Word 6.0 or Word 95.
Public propertyLevel Gets the list level number (0 to 8).
Public propertyNumberFormat Returns or sets the number format for the list level.
Public propertyNumberPosition Gets or sets the position (in points) of the number or bullet for the list level.
Public propertyNumberStyle Gets or sets the number style for this list level.
Public propertyParagraphFormat Gets or sets paragraph formatting used for the list level.
Public propertyRestartAfterLevel Gets or sets the list level that must appear before the specified list level restarts numbering.
Public propertyStartAt Gets or sets the starting number for this list level.
Public propertyTextPosition Gets or sets the position (in points) for the second line of wrapping text for the list level.
Public propertyTrailingCharacter Gets or sets the character inserted after the number for the list level.
Top
Methods
 NameDescription
Public methodClearFormatting Clears the formatting.
(Overrides FormatClearFormatting)
Public methodEquals Determines whether the specified object is equal to this ListLevelFormat instance.
(Overrides ObjectEquals(Object))
Top
Example

See Developer Guide: How to create a simple list

How to create a simple list in C#
using SautinSoft.Document;

namespace Sample
{
    class Sample
    {

        static void Main(string[] args)
        {
            // Get your free 100-day key here:   
            // https://sautinsoft.com/start-for-free/

            SimpleLists();
        }

        /// <summary>
        /// How to create a simple document with ordered and unordered lists. 
        /// </summary>
        /// <remarks>
        /// Details: https://sautinsoft.com/products/document/help/net/developer-guide/create-simple-list-in-pdf-document-net-csharp-vb.php
        /// </remarks>        
        public static void SimpleLists()
        {
            string documentPath = @"Lists.pdf";

            // Let's create a simple document.
            DocumentCore dc = new DocumentCore();

            // Add a new section.
            Section s = new Section(dc);
            dc.Sections.Add(s);

            string[] myCollection = new string[] { "One", "Two", "Three", "Four", "Five" };

            // Create new ordered list style.
            ListStyle ordList = new ListStyle("Simple Numbers", ListTemplateType.NumberWithDot);
            foreach (ListLevelFormat f in ordList.ListLevelFormats)
            {
                f.CharacterFormat.Size = 14;
            }
            dc.Styles.Add(ordList);

            // Add caption
            dc.Content.Start.Insert("This is a simple ordered list:", new CharacterFormat() { Size = 14.0, FontColor = Color.Black });

            // Add the collection of paragraphs marked as ordered list.
            int level = 0;
            foreach (string listText in myCollection)
            {
                Paragraph p = new Paragraph(dc);
                dc.Sections[0].Blocks.Add(p);

                p.Content.End.Insert(listText, new CharacterFormat() { Size = 14.0, FontColor = Color.Black });
                p.ListFormat.Style = ordList;
                p.ListFormat.ListLevelNumber = level;
                p.ParagraphFormat.SpaceAfter = 0;
            }

            // Add the collection of paragraphs marked as unordered list (bullets).

            // Add caption
            dc.Content.End.Insert("\n\nThis is a simple bulleted list:", new CharacterFormat() { Size = 14.0, FontColor = Color.Black });

            // Create list style.
            ListStyle bullList = new ListStyle("Bullets", ListTemplateType.Bullet);
            dc.Styles.Add(bullList);

            level = 0;
            foreach (string listText in myCollection)
            {
                Paragraph p = new Paragraph(dc);
                dc.Sections[0].Blocks.Add(p);

                p.Content.End.Insert(listText, new CharacterFormat() { Size = 14.0, FontColor = Color.Black });
                p.ListFormat.Style = bullList;
                p.ListFormat.ListLevelNumber = level;
                p.ParagraphFormat.SpaceAfter = 0;
            }

            // Save our document into PDF format.
            dc.Save(documentPath, new PdfSaveOptions() { Compliance = PdfCompliance.PDF_A1a });

            // Open the result for demonstration purposes.
            System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(documentPath) { UseShellExecute = true });
        }
    }
}
How to create a simple list in VB.Net
Imports System
Imports System.IO
Imports SautinSoft.Document

Module Sample
    Sub Main()
        SimpleLists()
    End Sub
    ''' Get your free 100-day key here:   
    ''' https://sautinsoft.com/start-for-free/
    ''' <summary>
    ''' How to create a simple document with ordered and unordered lists. 
    ''' </summary>
    ''' <remarks>
    ''' Details: https://sautinsoft.com/products/document/help/net/developer-guide/create-simple-list-in-pdf-document-net-csharp-vb.php
    ''' </remarks>
    Sub SimpleLists()
        Dim documentPath As String = "Lists.pdf"

        ' Let's create a simple document.
        Dim dc As New DocumentCore()

        ' Add a new section.
        Dim s As New Section(dc)
        dc.Sections.Add(s)

        Dim myCollection() As String = {"One", "Two", "Three", "Four", "Five"}

        ' Create new ordered list style.
        Dim ordList As New ListStyle("Simple Numbers", ListTemplateType.NumberWithDot)
        For Each f As ListLevelFormat In ordList.ListLevelFormats
            f.CharacterFormat.Size = 14
        Next f
        dc.Styles.Add(ordList)

        ' Add caption
        dc.Content.Start.Insert("This is a simple ordered list:", New CharacterFormat() With {
            .Size = 14.0,
            .FontColor = Color.Black
        })

        ' Add the collection of paragraphs marked as ordered list.
        Dim level As Integer = 0
        For Each listText As String In myCollection
            Dim p As New Paragraph(dc)
            dc.Sections(0).Blocks.Add(p)

            p.Content.End.Insert(listText, New CharacterFormat() With {
                .Size = 14.0,
                .FontColor = Color.Black
            })
            p.ListFormat.Style = ordList
            p.ListFormat.ListLevelNumber = level
            p.ParagraphFormat.SpaceAfter = 0
        Next listText

        ' Add the collection of paragraphs marked as unordered list (bullets).

        ' Add caption
        dc.Content.End.Insert(vbLf & vbLf & "This is a simple bulleted list:", New CharacterFormat() With {
            .Size = 14.0,
            .FontColor = Color.Black
        })

        ' Create list style.
        Dim bullList As New ListStyle("Bullets", ListTemplateType.Bullet)
        dc.Styles.Add(bullList)

        level = 0
        For Each listText As String In myCollection
            Dim p As New Paragraph(dc)
            dc.Sections(0).Blocks.Add(p)

            p.Content.End.Insert(listText, New CharacterFormat() With {
                .Size = 14.0,
                .FontColor = Color.Black
            })
            p.ListFormat.Style = bullList
            p.ListFormat.ListLevelNumber = level
            p.ParagraphFormat.SpaceAfter = 0
        Next listText

        ' Save our document into PDF format.
        dc.Save(documentPath, New PdfSaveOptions() With {.Compliance = PdfCompliance.PDF_A1a})

        ' Open the result for demonstration purposes.
        System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(documentPath) With {.UseShellExecute = True})
    End Sub
End Module
See Also