Class: SElement

Core.PDFNet. SElement


new SElement( [obj] [, k])

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)).
Parameters:
Name Type Argument Description
obj Core.PDFNet.Obj <optional>
k Core.PDFNet.Obj <optional>
Properties:
Name Type Description
obj Core.PDFNet.Obj
k Core.PDFNet.Obj

Methods


<static> create( [dict])

Initialize a SElement using an existing low-level Cos/SDF object.
Parameters:
Name Type Argument Description
dict Core.PDFNet.Obj <optional>
a low-level (SDF/Cos) dictionary representing the structural element. Note: This constructor does not copy any data, but is instead the logical equivalent of a type cast.
Returns:
A promise that resolves to an object of type: "PDFNet.SElement"
Type
Promise.<Core.PDFNet.SElement>

<static> createFromPDFDoc(doc, struct_type)

Creates a new SElement.
Parameters:
Name Type Description
doc Core.PDFNet.PDFDoc | Core.PDFNet.SDFDoc | Core.PDFNet.FDFDoc
struct_type string
Returns:
A promise that resolves to an object of type: "PDFNet.SElement"
Type
Promise.<Core.PDFNet.SElement>

createContentItem(doc, page [, insert_before])

Parameters:
Name Type Argument Description
doc Core.PDFNet.PDFDoc | Core.PDFNet.SDFDoc | Core.PDFNet.FDFDoc The document in which the new ContentItem will be created in.
page Core.PDFNet.Page The page object to insert the ContentItem in.
insert_before number <optional>
The position after which the kid is inserted. If element currently has no kids, insert_before is ignored.
Returns:
A promise that resolves to an object of type: "number"
Type
Promise.<number>

getActualText()

Returns:
A promise that resolves to the ActualText associated with this element. 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().
Type
Promise.<string>

getAlt()

Returns:
A promise that resolves to the alternate text associated with this element. 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().
Type
Promise.<string>

getAsContentItem(index)

Parameters:
Name Type Description
index number The index of the kid to obtain.
Returns:
A promise that resolves to the kid at a given array index assuming that the kid is a ContentItem. Note: use IsContentItem(index) prior to calling this method to make sure that the kid is indeed a ContentItem.
Type
Promise.<Core.PDFNet.ContentItem>

getAsStructElem(index)

Parameters:
Name Type Description
index number The index of the kid to obtain.
Returns:
A promise that resolves to the kid at a given array index assuming that the kid is a SElement. Note: use IsContentItem(index) prior to calling this method to make sure that the kid is not a ContentItem and is another SElement.
Type
Promise.<Core.PDFNet.SElement>

getID()

Returns:
A promise that resolves to the ID of an element, or NULL if the ID is not defined.
Type
Promise.<Core.PDFNet.Obj>

getNumKids()

Returns:
A promise that resolves to the number of direct kids.
Type
Promise.<number>

getParent()

Returns:
A promise that resolves to the immediate ancestor element of the specified element in the structure tree. 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.
Type
Promise.<Core.PDFNet.SElement>

getSDFObj()

Returns:
A promise that resolves to pointer to the underlying SDF/Cos object.
Type
Promise.<Core.PDFNet.Obj>

getStructTreeRoot()

Returns:
A promise that resolves to the structure tree root of the document that directly or indirectly contains this element.
Type
Promise.<Core.PDFNet.STree>

getTitle()

Returns:
A promise that resolves to the title of this structure element.
Type
Promise.<string>

getType()

Returns:
A promise that resolves to 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).
Type
Promise.<string>

hasActualText()

Returns:
A promise that resolves to 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.
Type
Promise.<boolean>

hasAlt()

Returns:
A promise that resolves to 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.
Type
Promise.<boolean>

hasTitle()

Returns:
A promise that resolves to if this SElement has title. The title of the structure element, a text string representing it in human-readable form.
Type
Promise.<boolean>

insert(kid, insert_before)

Parameters:
Name Type Description
kid Core.PDFNet.SElement
insert_before number
Returns:
Type
Promise.<void>

isContentItem(index)

Parameters:
Name Type Description
index number 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:
A promise that resolves to true if the kid at a given array index is a content item, false otherwise.
Type
Promise.<boolean>

isValid()

Returns:
A promise that resolves to true if this is a valid structure element object, false otherwise.
Type
Promise.<boolean>