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
From interface java.lang.AutoCloseable

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

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.

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.

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.

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.

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.

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.

public Obj getID ()

Get the ID of SElement

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

public int getNumKids ()

Get the num kids.

Returns
  • The number of direct kids.

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.

public Obj getSDFObj ()

Get the SDFObj.

Returns
  • Pointer to the underlying SDF/Cos object.

public STree getStructTreeRoot ()

Get root of the struct tree.

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

public String getTitle ()

Get the title of SElement

Returns
  • The title of this structure element.

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

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.

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.

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.

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.

public boolean isValid ()

Checks if SElement is valid.

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