GemBox.Document
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    TableOfEntries Class

    Namespace:
    GemBox.Document
    Assembly:
    GemBox.Document.dll

    Represents a Table of Entries field, such as Table of Contents, Table of Figures, Table of Authorities, Index or Bibliography.

    • C#
    • VB.NET
    public sealed class TableOfEntries : Block, IContentElement
    Public NotInheritable Class TableOfEntries
        Inherits Block
        Implements IContentElement
    Inheritance:
    System.Object
    Element
    Block
    TableOfEntries
    Implements
    IContentElement
    Remarks

    TableOfEntries is a Block element used to define fields that span more than one InlineCollection, as opposite to Field element that represent a fields that span only through single InlineCollection.

    Supported field types are: Index, TOC, TOA and Bibliography.

    TableOfEntries is a content element with Entries as a content property that accepts only Paragraphs.

    Constructors

    TableOfEntries(DocumentModel, FieldType)

    Initializes a new instance of the TableOfEntries class.

    • C#
    • VB.NET
    public TableOfEntries(DocumentModel document, FieldType fieldType)
    Public Sub New(document As DocumentModel, fieldType As FieldType)
    Parameters
    document
    DocumentModel

    The owner document.

    fieldType
    FieldType

    The field type. (supported are only Index, TOC, TOA and Bibliography).

    TableOfEntries(DocumentModel, FieldType, String, Block[])

    Initializes a new instance of the TableOfEntries class.

    • C#
    • VB.NET
    public TableOfEntries(DocumentModel document, FieldType fieldType, string instructionText, params Block[] entries)
    Public Sub New(document As DocumentModel, fieldType As FieldType, instructionText As String, ParamArray entries As Block())
    Parameters
    document
    DocumentModel

    The owner document.

    fieldType
    FieldType

    The field type. (supported are only Index, TOC, TOA and Bibliography).

    instructionText
    System.String

    The field's instruction text (switches).

    entries
    Block[]

    The table's entries.

    TableOfEntries(DocumentModel, FieldType, String, IEnumerable<Block>)

    Initializes a new instance of the TableOfEntries class.

    • C#
    • VB.NET
    public TableOfEntries(DocumentModel document, FieldType fieldType, string instructionText, IEnumerable<Block> entries)
    Public Sub New(document As DocumentModel, fieldType As FieldType, instructionText As String, entries As IEnumerable(Of Block))
    Parameters
    document
    DocumentModel

    The owner document.

    fieldType
    FieldType

    The field type. (supported are only Index, TOC, TOA and Bibliography).

    instructionText
    System.String

    The field's instruction text (switches).

    entries
    System.Collections.Generic.IEnumerable<Block>

    The table's entries.

    Properties

    ElementType

    Gets the ElementType of this Element instance.

    • C#
    • VB.NET
    public override ElementType ElementType { get; }
    Public Overrides ReadOnly Property ElementType As ElementType
    Property Value
    ElementType

    The ElementType of this Element instance.

    Overrides
    Element.ElementType

    Entries

    Gets the table's entries.

    • C#
    • VB.NET
    public BlockCollection Entries { get; }
    Public ReadOnly Property Entries As BlockCollection
    Property Value
    BlockCollection

    The table's entries.

    Remarks

    Only supported element type is Paragraph.

    FieldType

    Gets the field type.

    • C#
    • VB.NET
    public FieldType FieldType { get; }
    Public ReadOnly Property FieldType As FieldType
    Property Value
    FieldType

    The field type.

    InstructionText

    Gets or sets the field's instruction text (switches).

    • C#
    • VB.NET
    public string InstructionText { get; set; }
    Public Property InstructionText As String
    Property Value
    System.String

    The field's instruction text (switches).

    IsDirty

    Gets or sets a value indicating whether this TableOfEntries is invalid and, because of that, it should be updated.

    • C#
    • VB.NET
    public bool IsDirty { get; set; }
    Public Property IsDirty As Boolean
    Property Value
    System.Boolean

    true if result of this TableOfEntries is invalid and, because of that, it should be updated; otherwise, false.

    Remarks

    The property value of true specifies that the result of this field is no longer based on the contents of the document, and should be recalculated whenever an application with this functionality reads the document (for example MS Word).

    IsLocked

    Gets or sets a value indicating whether this TableOfEntries is locked and, because of that, it should not be updated.

    • C#
    • VB.NET
    public bool IsLocked { get; set; }
    Public Property IsLocked As Boolean
    Property Value
    System.Boolean

    true if result of this TableOfEntries is locked and, because of that, it should not be updated; otherwise, false.

    Remarks

    This property is simply written to a Word document and has no effect on the behavior of this library. When a field is locked, Word applications will not update its results.

    Parent

    Gets the parent Section of this TableOfEntries instance.

    • C#
    • VB.NET
    public Section Parent { get; }
    Public ReadOnly Property Parent As Section
    Property Value
    Section

    The parent Section of this TableOfEntries instance.

    Methods

    Clone(Boolean)

    Clones this TableOfEntries instance.

    • C#
    • VB.NET
    public TableOfEntries Clone(bool cloneDescendants)
    Public Function Clone(cloneDescendants As Boolean) As TableOfEntries
    Parameters
    cloneDescendants
    System.Boolean

    If set to true clone all descendants recursively; otherwise clone only current TableOfEntries.

    Returns
    TableOfEntries

    Cloned TableOfEntries.

    Remarks

    Document content element instance can exist only in a one place in the document.

    If you want to insert document content element into some other part of the same document, then clone the element and insert its clone.

    If you want to insert document content element into another document, then you should first import it into another document with Import<T>(T, Boolean, Boolean) method and then insert the imported element.

    For more information, see cloning example.

    Update()

    Performs an update on TOC (Table of Contents) field.

    • C#
    • VB.NET
    public void Update()
    Public Sub Update
    Remarks

    Update() method is used for updating entire TOC field with new entries.

    If InstructionText is not specified Update() method will set a default set of switches: \o "1-3" \h \u \z.

    GemBox.Document automatically updates page numbers in TOC entries only for PDF, XPS, and image formats, for DOCX format page numbers have a default value 1. Updating page numbers for TOC entries in DOCX can be achieved by creating an instance of PaginatorOptions, setting its UpdateFields to true, and calling the GetPaginator(PaginatorOptions) method with that PaginatorOptions instance.

    Supported TOC switches:
    • \o - Specifies the OutlineLevel of enlisting header paragraphs.
    • \u - Specifies enlistment of all paragraphs with OutlineLevel not equal to BodyText.
    • \t - Specifies enlistment of all paragraphs with defined custom styles.
    • \f - Specifies a unique identifier for TC fields enlistment.
    • \h - Specifies a Hyperlink usage.
    • \n - Specifies the OutlineLevel of entries with omitted page number.
    • \l - Specifies the OutlineLevel of enlisting TC fields.
    • \p - Specifies the character that separates entry and its page number.
    • \b - Specifies the name of the bookmark from which the paragraphs are enlisted.
    Supported TC switches:
    • \f - TC field's unique identifier.
    • \l - TC field's OutlineLevel.
    • \n - Omit page number.

    For more information about TOC switches, see Field codes: TOC (Table of Contents) field.

    For more information about TC switches, see Field codes: TC (Table of Contents Entry) field.

    Inherited Properties

    Content

    Gets the content of the current Element.

    (Inherited from Element)

    Document

    Gets the owner document.

    (Inherited from Element)

    ParentCollection

    Gets the BlockCollection that contains this Block instance.

    (Inherited from Block)

    Inherited Methods

    GetChildElements(System.Boolean)

    Gets the child elements.

    (Inherited from Element)

    GetChildElements(System.Boolean, ElementType[])

    Gets the child elements filtered by ElementType.

    (Inherited from Element)

    GetParentElements()

    Gets the parent elements.

    (Inherited from Element)

    GetParentElements(ElementType[])

    Gets the parent elements.

    (Inherited from Element)

    Implements

    IContentElement

    Examples

    Create and Update Word TOC in C# and VB.NET
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.