Aspose::Pdf::Text::TextSegment class

TextSegment class

Represents segment of Pdf text.

class TextSegment : public System::Object

Methods

MethodDescription
get_BaselinePosition() constGets text position for text, represented with TextSegment object. The YIndent of the Position structure represents baseline coordinate of the text segment.
get_Characters()Gets collection of CharInfo objects that represent information on characters in the text segment.
get_EndCharIndex() constGets ending character index of current segment in the show text operator (Tj, TJ) segment.
get_Hyperlink() constGets the segment hyperlink(for pdf generator).
get_Position() constGets text position for text, represented with TextSegment object.
get_Rectangle()Gets rectangle of the TextSegment.
get_StartCharIndex() constGets starting character index of current segment in the show text operator (Tj, TJ) segment.
get_Text() constGets System::String text object that the TextSegment object represents.
get_TextEditOptions() constGets text edit options. The options define special behavior when requested symbol cannot be written with font.
get_TextState() constGets text state for the text that TextSegment object represents.
static MyHtmlEncode(System::String)Encodes string as html.
set_BaselinePosition(System::SharedPtr<Aspose::Pdf::Text::Position>)Gets text position for text, represented with TextSegment object. The YIndent of the Position structure represents baseline coordinate of the text segment.
set_Hyperlink(System::SharedPtr<Aspose::Pdf::Hyperlink>)Sets the segment hyperlink(for pdf generator).
set_Position(System::SharedPtr<Aspose::Pdf::Text::Position>)Gets text position for text, represented with TextSegment object.
set_Text(System::String)Sets System::String text object that the TextSegment object represents.
set_TextEditOptions(System::SharedPtr<Aspose::Pdf::Text::TextEditOptions>)Sets text edit options. The options define special behavior when requested symbol cannot be written with font.
set_TextState(System::SharedPtr<Aspose::Pdf::Text::TextState>)Sets text state for the text that TextSegment object represents.
TextSegment()Creates TextSegment object.
TextSegment(System::String)Creates TextSegment object.

Remarks

In a few words, TextSegment objects are children of TextFragment object.

In details:

Text of pdf document in Aspose::Pdf is represented by two basic objects: TextFragment and TextSegment

The differences between them is mostly context-dependent.

Let’s consider following scenario. User searches text “hello world” to operate with it, change it’s properties, look etc.

Document doc = new Document(docFile);
TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world");
doc.Pages[1].Accept(absorber);

Phisycally pdf text’s representation is very complex. The text “hello world” may consist of several phisycally independent text segments.

The Aspose.Pdf text model basically establishes that TextFragment object provides single logic operation set over physical TextSegment objects set that represent user’s query.

In text search scenario, TextFragment is logical “hello world” text representation, and TextSegment object collection represents all physical segments that construct “hello world” text object.

So, TextFragment is close to logical text representation. And TextSegment is close to physical text representation.

Obviously each TextSegment object may have it’s own font, coloring, positioning properties.

TextFragment provides simple way to change text with it’s properties: set font, set font size, set font color etc. Meanwhile TextSegment objects are accessible and users are able to operate with TextSegment objects independently.

See Also