Aspose::Pdf::Text::TextFragment class
TextFragment class
Represents fragment of Pdf text.
class TextFragment : public Aspose::Pdf::BaseParagraph
Methods
Method | Description |
---|---|
Clone() override | Clone 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() const | Gets the paragraph end note.(for pdf generation only) |
get_FootNote() const | Gets the paragraph foot note.(for pdf generation only) |
get_Form() const | Gets form object that contains the TextFragment. |
get_HorizontalAlignment() override | Gets a horizontal alignment of text fragment. |
get_Page() const | Gets 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() const | Gets text replace options. The options define behavior when fragment text is replaced to more short/long. |
get_Segments() const | Gets text segments for current TextFragment. |
get_Text() | Gets System::String text object that the TextFragment object represents. |
get_TextEditOptions() const | Gets text edit options. The options define special behavior when requested symbol cannot be written with font. |
get_TextState() | Gets text state for the text that TextFragment object represents. |
get_VerticalAlignment() override | Gets a vertical alignment of text fragment. |
get_WrapLinesCount() const | Gets wrap lines count for this paragraph(for pdf generation only) |
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) override | Sets a horizontal alignment of text fragment. |
set_Hyperlink(System::SharedPtr<Aspose::Pdf::Hyperlink>) override | Sets the fragment hyperlink. |
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_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_VerticalAlignment(Aspose::Pdf::VerticalAlignment) override | Sets a vertical alignment of text fragment. |
set_WrapLinesCount(int32_t) | Sets wrap lines count for this paragraph(for pdf generation only) |
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
- Class BaseParagraph
- Namespace Aspose::Pdf::Text
- Library Aspose.PDF for C++