Summary: Ctors | Methods | Inherited Methods | [Expand All]
public class

# SElement

extends Object
implements AutoCloseable

java.lang.Object
↳ | com.pdftron.pdf.struct.SElement

## Class Overview

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)).

## Summary

Public Constructors
| SElement() Instantiates a new SElement.
| SElement(Obj dict) Initialize a SElement using an existing low-leval Cos/SDF object.

Public Methods
static SElement | __Create(long impl, Object ref)
void | close() Frees the native memory of the object.
void | destroy() Frees the native memory of the object.
String | getActualText() Get contained ActualText Note: The ActualText can be defined as an empty string.
String | getAlt() Get the alternate description of the SElement Note: The Alt text can be defined as an empty string.
ContentItem | getAsContentItem(int index) Get the kid at give index as a ContentItem.
SElement | getAsStructElem(int index) Get the kid at give index as SElement.
Obj | getID() Get the ID of SElement
int | getNumKids() Get the num kids.
SElement | getParent() Get the parent as SElement Note: If the element's parent is the structure tree root, the returned SElement will be not valid (i.e.
Obj | getSDFObj() Get the SDFObj.
STree | getStructTreeRoot() Get root of the struct tree.
String | getTitle() Get the title of SElement
String | getType() Get the structural element type
boolean | hasActualText() Checks if SElement has ActualText
boolean | hasAlt() Checks if SElement has alternate description
boolean | hasTitle() Checks if SElement has title.
boolean | isContentItem(int index) Checks if SElement is content item.
boolean | isValid() Checks if SElement is valid.

[Expand] Inherited Methods
From class java.lang.Object
boolean | equals(Object arg0)
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()
From interface java.lang.AutoCloseable
abstract void | close()

## Public Constructors

#### public SElement ()

Instantiates a new SElement.

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

##### Throws

PDFNetException | the PDF net exception

#### public SElement (Obj dict)

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

##### Parameters

dict | the dict

##### Throws

PDFNetException |

## Public Methods

#### public static SElement __Create (long impl, Object ref)

#### public void close ()

Frees the native memory of the object. This can be explicity called to control the deallocation of native memory and avoid situations where the garbage collector does not free the object in a timely manner.

##### Throws

PDFNetException |

#### public void destroy ()

Frees the native memory of the object. This can be explicity called to control the deallocation of native memory and avoid situations where the garbage collector does not free the object in a timely manner.

##### Throws

PDFNetException |

#### public String getActualText ()

Get contained ActualText

Note: 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().

##### Returns

- The ActualText associated with this element.

##### Throws

PDFNetException |

#### public String getAlt ()

Get the alternate description of the SElement

Note: 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().

##### Returns

- The alternate text associated with this element.

##### Throws

PDFNetException |

#### public ContentItem getAsContentItem (int index)

Get the kid at give index as a ContentItem.

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

##### Parameters

index | The index of the kid to obtain.

##### Returns

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

##### Throws

PDFNetException |

#### public SElement getAsStructElem (int index)

Get the kid at give index as SElement.

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

##### Parameters

index | The index of the kid to obtain.

##### Returns

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

##### Throws

PDFNetException |

#### public Obj getID ()

Get the ID of SElement

##### Returns

- the ID of an element, or NULL if the ID is not defined.

##### Throws

PDFNetException |

#### public int getNumKids ()

Get the num kids.

##### Returns

- The number of direct kids.

##### Throws

PDFNetException |

#### public SElement getParent ()

Get the parent as SElement

Note: 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.

##### Returns

- The immediate ancestor element of the specified element in the structure tree.

##### Throws

PDFNetException |

#### public Obj getSDFObj ()

Get the SDFObj.

##### Returns

- Pointer to the underlying SDF/Cos object.

##### Throws

PDFNetException |

#### public STree getStructTreeRoot ()

Get root of the struct tree.

##### Returns

- The structure tree root of the document that directly or indirectly contains this element.

##### Throws

PDFNetException |

#### public String getTitle ()

Get the title of SElement

##### Returns

- The title of this structure element.

##### Throws

PDFNetException |

#### public String getType ()

Get the structural element type

##### Returns

- 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).

##### Throws

PDFNetException |

#### public boolean hasActualText ()

Checks if SElement has ActualText

##### Returns

- 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.

##### Throws

PDFNetException |

#### public boolean hasAlt ()

Checks if SElement has alternate description

##### Returns

- 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.

##### Throws

PDFNetException |

#### public boolean hasTitle ()

Checks if SElement has title.

##### Returns

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

##### Throws

PDFNetException |

#### public boolean isContentItem (int index)

Checks if SElement is content item.

##### Parameters

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

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

##### Throws

PDFNetException |

#### public boolean isValid ()

Checks if SElement is valid.

##### Returns

- true if this is a valid structure element object, false otherwise.

##### Throws

PDFNetException |