[]
        
(Showing Draft Content)

GrapeCity.Documents.Pdf.Recognition.Structure.Element

Class Element

Namespace
GrapeCity.Documents.Pdf.Recognition.Structure
Assembly
GcDocs.Pdf.dll

Represents a parsed PDF tag (structure element) in the document's logical structure.

An instance of this class is created from a StructElement, and holds a reference to that object in its StructElement property.

public class Element : LogicalStructureItem
Inheritance
object
Element
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()

Properties

Children

Gets the list of current element's child elements.

Note that even if the current element has no children, accessing this property initializes the list. To simply check whether the element has any children, use HasChildren.

public IReadOnlyList<Element> Children { get; }

Property Value

System.Collections.Generic.IReadOnlyList<T><Element>

ContentItems

Gets the list of content items associated with the current element.

Note that even if the current element has no associated content items, accessing this property initializes the list. To simply check whether the element has any associated content items, use HasContentItems.

public IReadOnlyList<ContentItemBase> ContentItems { get; }

Property Value

System.Collections.Generic.IReadOnlyList<T><ContentItemBase>

HasChildren

Gets a value indicating whether the current element has any children Element objects (the Children list is not empty).

Note that even if the current element has no children, accessing Children will initialize it, so using this property is recommended when checking whether an element has any children.

public bool HasChildren { get; }

Property Value

bool

HasContentItems

Gets a value indicating whether the current element has any content items associated with it (the ContentItems list is not empty).

Note that even if there are no associated content items, accessing ContentItems will initialize it, so using this property is recommended when checking whether an element has any associated content items.

public bool HasContentItems { get; }

Property Value

bool

HasItems

Gets a value indicating whether the current element has any children (the Items list is not empty).

Note that even if the current element has no children, accessing Items will initialize it, so using this property is recommended when checking whether an element has any children.

public bool HasItems { get; }

Property Value

bool

Items

Gets the list of current element's child elements.

Note that even if the current element has no children, accessing this property initializes the list. To simply check whether the element has any children, use HasItems.

public List<LogicalStructureItem> Items { get; }

Property Value

System.Collections.Generic.List<T><LogicalStructureItem>

LogicalStructure

Gets the document logical structure to which this element belongs.

public LogicalStructure LogicalStructure { get; }

Property Value

LogicalStructure

Parent

Gets the parent of the current element.

public Element Parent { get; }

Property Value

Element

StructElement

Gets the structure element (PDF tag) that was used to create this element.

public StructElement StructElement { get; }

Property Value

StructElement

Type

Gets the Type if it is not null. Gets an empty string if Type is null.

public string Type { get; }

Property Value

string

Methods

FindChild(Func<Element, bool>, bool)

Iterates over child elements of this Element or its children, and returns an Element that matches a criteria specified via a callback.

public Element FindChild(Func<Element, bool> callback, bool recursive = true)

Parameters

callback System.Func<T, TResult><Element, bool>

The callback method used to test the elements.

recursive bool

Indicates whether to iterate over child elements' children.

Returns

Element

The first element for which the callback returned true, or null if no such element exists.

FindContentItem(Func<ContentItemBase, bool>, bool)

Iterates over content items that belong to this Element or its children, and returns a ContentItem that matches a criteria specified via a callback.

public ContentItemBase FindContentItem(Func<ContentItemBase, bool> callback, bool recursive = true)

Parameters

callback System.Func<T, TResult><ContentItemBase, bool>

The callback method used to test the content items.

recursive bool

Indicates whether to iterate over content items of child elements.

Returns

ContentItemBase

The first content item for which the callback returned true, or null if no such item exists.

GetFullType()

Builds and returns the dot-delimited full name of this element including all parent elements' names.

The result looks like "xxx.yyy.Type".

public string GetFullType()

Returns

string

GetImages()

Returns the list of PdfImageInfo objects associated with the current element.

public IList<PdfImageInfo> GetImages()

Returns

System.Collections.Generic.IList<T><PdfImageInfo>

The list of images associated with this element.

GetParagraphs()

Returns the list of ITextParagraph objects representing the content associated with the current element.

public IList<ITextParagraph> GetParagraphs()

Returns

System.Collections.Generic.IList<T><ITextParagraph>

The list of paragraphs associated with this element.

GetText()

Returns the text associated with this element. This method calls GetParagraphs() and returns an empty string if that method returns null.

public string GetText()

Returns

string

The text associated with this element, or an empty string.