Aspose::Pdf::Text::TextFragment class

TextFragment class

Represents fragment of Pdf text.

class TextFragment : public Aspose::Pdf::BaseParagraph

Methods

MethodDescription
BaseParagraph()
Clone() overrideClone the fragment.
virtual CloneWithSegments()Clone the fragment with all segments.
get_BaselinePosition()Gets text position for text, represented with TextFragment object. The YIndent of the Position structure represents baseline coordinate of the text fragment.
get_EndNote() constGets the paragraph end note.(for pdf generation only)
get_FootNote() constGets the paragraph foot note.(for pdf generation only)
get_Form() constGets form object that contains the TextFragment.
get_HorizontalAlignment() overrideGets a horizontal alignment of text fragment.
virtual get_Hyperlink()Gets the fragment hyperlink(for pdf generator).
get_IsFirstParagraphInColumn() constGets a bool value that indicates whether this paragraph will be at next column. Default is false.(for pdf generation)
get_IsInLineParagraph() constGets a paragraph is inline. Default is false.(for pdf generation)
get_IsInNewPage() constGets a bool value that force this paragraph generates at new page. Default is false.(for pdf generation)
get_IsKeptWithNext() constGets a bool value that indicates whether current paragraph remains in the same page along with next paragraph. Default is false.(for pdf generation)
get_Margin()Gets a outer margin for paragraph (for pdf generation)
get_Page() constGets page that contains the TextFragment.
get_Position()Gets text position for text, represented with TextFragment object.
get_Rectangle()Gets rectangle of the TextFragment.
get_ReplaceOptions() constGets text replace options. The options define behavior when fragment text is replaced to more short/long.
get_Segments() constGets text segments for current TextFragment.
get_Text()Gets System::String text object that the TextFragment object represents.
get_TextState()Gets text state for the text that TextFragment object represents.
get_VerticalAlignment() overrideGets a vertical alignment of text fragment.
get_WrapLinesCount() constGets wrap lines count for this paragraph(for pdf generation only)
get_ZIndex() constGets a int value that indicates the Z-order of the graph. A graph with larger ZIndex will be placed over the graph with smaller ZIndex. ZIndex can be negative. Graph with negative ZIndex will be placed behind the text in the page.
IsolateTextSegments(int32_t, int32_t)Gets TextSegment(s) representing specified part of the TextFragment text.
set_BaselinePosition(System::SharedPtr<Aspose::Pdf::Text::Position>)Gets text position for text, represented with TextFragment object. The YIndent of the Position structure represents baseline coordinate of the text fragment.
set_EndNote(System::SharedPtr<Note>)Sets the paragraph end note.(for pdf generation only)
set_FootNote(System::SharedPtr<Note>)Sets the paragraph foot note.(for pdf generation only)
set_HorizontalAlignment(Aspose::Pdf::HorizontalAlignment) overrideSets a horizontal alignment of text fragment.
set_Hyperlink(System::SharedPtr<Aspose::Pdf::Hyperlink>) overrideSets the fragment hyperlink.
set_IsFirstParagraphInColumn(bool)Sets a bool value that indicates whether this paragraph will be at next column. Default is false.(for pdf generation)
set_IsInLineParagraph(bool)Sets a paragraph is inline. Default is false.(for pdf generation)
set_IsInNewPage(bool)Sets a bool value that force this paragraph generates at new page. Default is false.(for pdf generation)
set_IsKeptWithNext(bool)Sets a bool value that indicates whether current paragraph remains in the same page along with next paragraph. Default is false.(for pdf generation)
set_Margin(System::SharedPtr<MarginInfo>)Sets a outer margin for paragraph (for pdf generation)
set_Position(System::SharedPtr<Aspose::Pdf::Text::Position>)Sets text position for text, represented with TextFragment object.
set_Segments(System::SharedPtr<TextSegmentCollection>)Gets text segments for current TextFragment.
set_Text(System::String)Sets System::String text object that the TextFragment object represents.
set_VerticalAlignment(Aspose::Pdf::VerticalAlignment) overrideSets a vertical alignment of text fragment.
set_WrapLinesCount(int32_t)Sets wrap lines count for this paragraph(for pdf generation only)
set_ZIndex(int32_t)Sets a int value that indicates the Z-order of the graph. A graph with larger ZIndex will be placed over the graph with smaller ZIndex. ZIndex can be negative. Graph with negative ZIndex will be placed behind the text in the page.
TextFragment()Initializes new instance of the TextFragment object.
TextFragment(System::SharedPtr<TabStops>)Initializes new instance of the TextFragment object with predefined TabStops positions.
TextFragment(System::String)Creates TextFragment object with single TextSegment object inside. Specifies text string inside the segment.
TextFragment(System::String, System::SharedPtr<TabStops>)Creates TextFragment object with single TextSegment object inside and predefined TabStops positions.

Remarks

In a few words, TextFragment object contains list of TextSegment objects.

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.

Note that changing TextFragment properties may change inner Segments collection because TextFragment is an aggregate object and it may rearrange internal segments or merge them into single segment. If your requirement is to leave the Segments collection unchanged, please change inner segments individually.

See Also