Show / Hide Table of Contents

# Class SElement

SElement represents PDF structural elements, which are nodes in a tree
structure, defining a PDF document's logical structure.

Unlike the StructTree, SElement can have two different kinds of children: another SElement or a ContentItem (which can be marked content (MC), or a PDF object reference (OBJR)).

##### Inheritance

object
SElement

##### Implements

IDisposable

##### Inherited Members

object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.MemberwiseClone()

###### Namespace: pdftron.PDF.Struct

###### Assembly: PDFNet.dll

##### Syntax

    public class SElement : IDisposable

### Constructors

#### SElement(PDFDoc, string)

Create `SElement` with specified type

##### Declaration

    public SElement(PDFDoc doc, string struct_type)

##### Parameters

Type | Name | Description
--- | --- | ---
PDFDoc | doc | PDF document to create the `SElement` in
string | struct_type | structure type

#### SElement(Obj)

Initialize a SElement using an existing low-leval Cos/SDF object.

##### Declaration

    public SElement(Obj dict)

##### Parameters

Type | Name | Description
--- | --- | ---
Obj | dict | the dict

##### Remarks

This constructor does not copy any data, but is instead the logical equivalent of a type cast.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

### Methods

#### CreateContentItem(PDFDoc, Obj, int)

Creates content item

##### Declaration

    public int CreateContentItem(PDFDoc doc, Obj page, int insert_before)

##### Parameters

Type | Name | Description
--- | --- | ---
PDFDoc | doc |
Obj | page |
int | insert_before | The position after which the kid is inserted. If element currently has no kids, insert_before is ignored.

##### Returns

Type | Description
--- | ---
int |

#### Dispose()

Releases all resources used by the SElement

##### Declaration

    public override sealed void Dispose()

#### Dispose(bool)

##### Declaration

    [HandleProcessCorruptedStateExceptions]
    protected virtual void Dispose(bool A_0)

##### Parameters

Type | Name | Description
--- | --- | ---
bool | A_0 |

#### ~SElement()

##### Declaration

    protected ~SElement()

#### GetActualText()

Checks for actual text.

##### Declaration

    public string GetActualText()

##### Returns

Type | Description
--- | ---
string | if this structure element defines ActualText. ActualText is an exact replacement for the structure element and its children. This replacement text is useful when extracting the document's contents in support of accessibility to users with disabilities or for other purposes.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### GetAlt()

Gets the alt.

##### Declaration

    public string GetAlt()

##### Returns

Type | Description
--- | ---
string | The alternate text associated with this element.

##### Remarks

The Alt text can be defined as an empty string. To differentiate between an Alt text string of zero length and no Alt text being defined, use HasAlt().

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### GetAsContentItem(int)

Gets the as content item.

##### Declaration

    public ContentItem GetAsContentItem(int index)

##### Parameters

Type | Name | Description
--- | --- | ---
int | index | The index of the kid to obtain.

##### Returns

Type | Description
--- | ---
ContentItem | The kid at a given array index assuming that the kid is a ContentItem.

##### Remarks

use IsContentItem(index) prior to calling this method to make sure that the kid is indeed a ContentItem.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### GetAsStructElem(int)

Gets the as struct elem.

##### Declaration

    public SElement GetAsStructElem(int index)

##### Parameters

Type | Name | Description
--- | --- | ---
int | index | The index of the kid to obtain.

##### Returns

Type | Description
--- | ---
SElement | The kid at a given array index assuming that the kid is a SElement.

##### Remarks

use IsContentItem(index) prior to calling this method to make sure that the kid is not a ContentItem and is another SElement.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### GetID()

Gets the ID.

##### Declaration

    public Obj GetID()

##### Returns

Type | Description
--- | ---
Obj | the ID of an element, or NULL if the ID is not defined.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### GetNumKids()

Gets the num kids.

##### Declaration

    public int GetNumKids()

##### Returns

Type | Description
--- | ---
int | The number of direct kids.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### GetParent()

Gets the parent.

##### Declaration

    public SElement GetParent()

##### Returns

Type | Description
--- | ---
SElement | The immediate ancestor element of the specified element in the structure tree.

##### Remarks

If the element's parent is the structure tree root, the returned SElement will be not valid (i.e. element.IsValid() -> false) and the underlying SDF/Cos object will be NULL.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### GetSDFObj()

Gets the sDF obj.

##### Declaration

    public Obj GetSDFObj()

##### Returns

Type | Description
--- | ---
Obj | Pointer to the underlying SDF/Cos object.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### GetStructTreeRoot()

Gets the struct tree root

##### Declaration

    public STree GetStructTreeRoot()

##### Returns

Type | Description
--- | ---
STree | structure tree root of the document that directly or indirectly contains this element

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### GetTitle()

Gets the title.

##### Declaration

    public string GetTitle()

##### Returns

Type | Description
--- | ---
string | The title of this structure element.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### GetType()

Gets the type.

##### Declaration

    public string GetType()

##### Returns

Type | Description
--- | ---
string | The element's structural element type. The type corresponds to the 'S' (i.e. subtype) key in the structure element dictionary. The type identifies the nature of the structure element and its role within the document (such as a chapter, paragraph, or footnote).

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### HasActualText()

Gets the actual text.

##### Declaration

    public bool HasActualText()

##### Returns

Type | Description
--- | ---
bool | The ActualText associated with this element.

##### Remarks

The ActualText can be defined as an empty string. To differentiate between an ActualText string of zero length and no ActualText being defined, use HasActualText().

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### HasAlt()

Checks for alt.

##### Declaration

    public bool HasAlt()

##### Returns

Type | Description
--- | ---
bool | if this structure element defines Alt text. Alt text is an alternate description of the structure element and its children in human-readable form, which is useful when extracting the document's contents in support of accessibility.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### HasTitle()

Checks for title.

##### Declaration

    public bool HasTitle()

##### Returns

Type | Description
--- | ---
bool | if this SElement has title. The title of the structure element, a text string representing it in human-readable form.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### Insert(SElement, int)

##### Declaration

    public void Insert(SElement kid, int insert_before)

##### Parameters

Type | Name | Description
--- | --- | ---
SElement | kid |
int | insert_before |

#### IsContentItem(int)

Checks if is content item.

##### Declaration

    public bool IsContentItem(int index)

##### Parameters

Type | Name | Description
--- | --- | ---
int | index | The index of the kid type to obtain. To retrieve a content item at a given array index use GetAsContentItem(index), otherwise use GetAsStructElem(index)

##### Returns

Type | Description
--- | ---
bool | true if the kid at a given array index is a content item, false otherwise.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### IsValid()

Checks if is valid.

##### Declaration

    public bool IsValid()

##### Returns

Type | Description
--- | ---
bool | true if this is a valid structure element object, false otherwise.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

### Implements

IDisposable