PTSElement

@interface PTSElement : NSObject

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

  • Creates a new SElement.

    Declaration

    Objective-C

    + (PTSElement *)Create:(PTPDFDoc *)doc struct_type:(NSString *)struct_type;

    Swift

    class func create(_ doc: PTPDFDoc!, struct_type: String!) -> PTSElement!

    Parameters

    doc

    struct_type

  • Inserts the specified kid SElement into this element.

    Declaration

    Objective-C

    - (void)Insert:(PTSElement *)kid insert_before:(int)insert_before;

    Swift

    func insert(_ kid: PTSElement!, insert_before: Int32)

    Parameters

    insert_before

    The position after which the kid is inserted. If element currently has no kids, insert_before is ignored.

  • Declaration

    Objective-C

    - (int)CreateContentItem:(PTPDFDoc *)doc
                        page:(PTPage *)page
               insert_before:(int)insert_before;

    Swift

    func createContentItem(_ doc: PTPDFDoc!, page: PTPage!, insert_before: Int32) -> Int32

    Parameters

    doc

    The document in which the new ContentItem will be created in.

    page

    The page object to insert the ContentItem in.

    insert_before

    The position after which the kid is inserted. If element currently has no kids, insert_before is ignored.

  • Declaration

    Objective-C

    - (BOOL)IsValid;

    Swift

    func isValid() -> Bool

    Return Value

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

  • The type identifies the nature of the structure element and its role within the document (such as a chapter, paragraph, or footnote).

    Declaration

    Objective-C

    - (NSString *)GetType;

    Swift

    func getType() -> String!

    Return Value

    The element’s structural element type. The type corresponds to the ‘S’ (i.e. subtype) key in the structure element dictionary.

  • Declaration

    Objective-C

    - (int)GetNumKids;

    Swift

    func getNumKids() -> Int32

    Return Value

    The number of direct kids.

  • To retrieve a content item at a given array index use GetAsContentItem(index), otherwise use GetAsStructElem(index)

    Declaration

    Objective-C

    - (BOOL)IsContentItem:(int)index;

    Swift

    func isContentItem(_ index: Int32) -> Bool

    Parameters

    index

    The index of the kid type to obtain.

    Return Value

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

  • Note

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

    Declaration

    Objective-C

    - (PTContentItem *)GetAsContentItem:(int)index;

    Swift

    func getAsContentItem(_ index: Int32) -> PTContentItem!

    Parameters

    index

    The index of the kid to obtain.

    Return Value

    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 not a ContentItem and is another SElement.

    Declaration

    Objective-C

    - (PTSElement *)GetAsStructElem:(int)index;

    Swift

    func getAsStructElem(_ index: Int32) -> PTSElement!

    Parameters

    index

    The index of the kid to obtain.

    Return Value

    The kid at a given array index assuming that the kid is a 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.

    Declaration

    Objective-C

    - (PTSElement *)GetParent;

    Swift

    func getParent() -> PTSElement!

    Return Value

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

  • Declaration

    Objective-C

    - (PTSTree *)GetStructTreeRoot;

    Swift

    func getStructTreeRoot() -> PTSTree!

    Return Value

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

  • The title of the structure element, a text string representing it in human-readable form.

    Declaration

    Objective-C

    - (BOOL)HasTitle;

    Swift

    func hasTitle() -> Bool

    Return Value

    if this SElement has title.

  • Declaration

    Objective-C

    - (NSString *)GetTitle;

    Swift

    func getTitle() -> String!

    Return Value

    The title of this structure element.

  • Declaration

    Objective-C

    - (PTObj *)GetID;

    Swift

    func getID() -> PTObj!

    Return Value

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

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

    Declaration

    Objective-C

    - (BOOL)HasActualText;

    Swift

    func hasActualText() -> Bool

    Return Value

    if this structure element defines 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().

    Declaration

    Objective-C

    - (NSString *)GetActualText;

    Swift

    func getActualText() -> String!

    Return Value

    The ActualText associated with this element.

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

    Declaration

    Objective-C

    - (BOOL)HasAlt;

    Swift

    func hasAlt() -> Bool

    Return Value

    if this structure element defines Alt text.

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

    Declaration

    Objective-C

    - (NSString *)GetAlt;

    Swift

    func getAlt() -> String!

    Return Value

    The alternate text associated with this element.

  • Declaration

    Objective-C

    - (PTObj *)GetSDFObj;

    Swift

    func getSDFObj() -> PTObj!

    Return Value

    Pointer to the underlying SDF/Cos object.

  • Undocumented

    Declaration

    Objective-C

    - (instancetype)initWithDict: (PTObj*)dict;

    Swift

    init!(dict: PTObj!)