TextFragment
Overview
TextFragment is a class in Aspose.PDF FOSS for .NET.
Inherits from: BaseParagraph.
Represents a fragment of text on a page with position and style information.
This class provides 8 methods for working with TextFragment objects in .NET programs.
Available methods include: Clone, CloneWithSegments, IsolateTextSegments, TextFragment.
All public members are accessible to any .NET application after installing the Aspose.PDF FOSS for .NET package.
Properties: BaselinePosition, EndNote, FontSize, FootNote, Form, HorizontalAlignment, and 20 more.
Properties
| Name | Type | Access | Description |
|---|---|---|---|
TabStops | TabStops? | Read/Write | Tab stops for this fragment (used with #$TAB markers in text). |
TextEditOptions | TextEditOptions | Read/Write | Edit options applied during text replacement / font substitution. |
IsInLineParagraph | bool | Read/Write | When true, this text fragment renders on the same line as the previous in-line paragraph (see docs.aspose.com/pdf/net/add-text-to-pdf-file “inline paragraphs”). |
IsInNewPage | bool | Read/Write | Gets or sets the is in new page. |
VerticalAlignment | VerticalAlignment | Read/Write | Gets or sets the vertical alignment. |
Text | string | Read/Write | The text content. |
ReplaceOptions | TextReplaceOptions | Read | Text-replacement options used by TextFragmentAbsorber replace paths. |
Page | Page? | Read | The page this fragment belongs to (public alias for SourcePage). |
Form | XForm? | Read | The XForm this fragment was extracted from, or null for page-level fragments. |
FootNote | Note? | Read/Write | Optional footnote attached to this fragment. |
HorizontalAlignment | HorizontalAlignment | Read/Write | Horizontal alignment used when this fragment is laid out as a paragraph (added to page.Paragraphs). |
Rectangle | Rectangle? | Read | The bounding rectangle of this text fragment on the page. |
Position | Position? | Read/Write | The text position. |
BaselinePosition | Position? | Read/Write | The text baseline position. |
Margin | MarginInfo | Read/Write | Margin information for layout when used as a paragraph element. |
TextState | TextFragmentState | Read | Text state (font, size, color). |
PageIndex | int | Read | The page index (0-based) this fragment was found on. |
FontSize | double | Read | Shortcut for TextState.FontSize. |
Segments | TextSegmentCollection | Read/Write | The collection of text segments that make up this fragment (1-indexed). |
Hyperlink | Hyperlink | Read/Write | Hyperlink applied to this fragment. |
EndNote | Note? | Read/Write | Endnote attached to this fragment. |
WrapLinesCount | int | Read/Write | Number of wrapped lines computed during layout. |
IsFirstParagraphInColumn | bool | Read/Write | Force the paragraph to start a new column. |
IsKeptWithNext | bool | Read/Write | Keep this paragraph on the same page as the next one. |
HyperlinkText | string? | Read/Write | Legacy string-typed hyperlink target. |
ZIndex | int | Read/Write | Z-order index used by the DOM renderer. |
Methods
| Signature | Description |
|---|---|
TextFragment() | Create a text fragment with tab stops. |
TextFragment(tabStops: TabStops) | Calls TextFragment on this TextFragment instance. |
TextFragment(text: string) | Create a text fragment with the given text. |
TextFragment(text: string, tabStops: TabStops) | Create a text fragment with the given text and tabStops resolution table. |
TextFragment(text: string, rectangle: Rectangle?, textState: TextState?) | |
IsolateTextSegments(startIndex: int, length: int) | Return text segments covering the given character range (startIndex is 1-based). |
Clone() | Shallow copy of the fragment (text + state). |
CloneWithSegments() | Clone the fragment AND its segments. |