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 declares 9 methods for TextFragment objects in .NET programs.
Available methods include: BaseParagraph, Clone, CloneWithSegments, IsolateTextSegments, TextFragment.
Public members are accessible to any .NET application after installing the Aspose.PDF FOSS for .NET package.
Properties: BaselinePosition, BlockBackgroundPictures, BlockBorder, BlockBoxed, BlockCornerRadii, BlockHorizontalAlignment, and 34 more.
Properties
| Name | Type | Access | Description |
|---|---|---|---|
TextEditOptions | TextEditOptions | Read/Write | Edit options applied during text replacement / font substitution. |
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. |
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. |
BlockBorder | BorderInfo? | Read/Write | A border drawn around the paragraph’s BLOCK when it flows on a page: around its padding and line boxes, inside its Margin. |
BlockPadding | MarginInfo? | Read/Write | Space between the block’s border (or its edge) and its line boxes, on each side. |
BlockWidth | double | Read/Write | The width of the block’s CONTENT – its line boxes – in points; padding and border add outside it. |
BlockMaxWidth | double | Read/Write | The most the block’s content may be wide; the block shrinks to it when the region is wider. |
BoxHeight | double | Read/Write | The height of the block’s content box, in points; padding and border add outside it. |
BoxMinHeight | double | Read/Write | The least the block’s content box may be tall. |
BoxMaxHeight | double | Read/Write | The most the block’s content box may be tall: a taller content is cut to it, lines beyond dropped, and a declared BoxHeight above it is brought down to it; the floor wins over it. |
BlockMinWidth | double | Read/Write | The least the block’s content box may be wide: a narrower declared or fitted width grows to it. |
BlockHorizontalAlignment | HorizontalAlignment | Read/Write | Where a block narrower than its region stands across it. |
BlockVerticalAlignment | VerticalAlignment | Read/Write | Where a SINGLE line stands inside a content box taller than it is. |
BlockBoxed | bool | Read/Write | Lays the fragment as a block box even when no other block property is set – what makes the flow honour its Margin’s LEFT and RIGHT, which a plain flow fragment has never taken. |
BlockCornerRadii | CornerRadii? | Read/Write | Rounds the block’s corners (see CornerRadii): the background is painted inside the rounded outline and the BlockBorder inside the ring between it and the inner outline. |
BlockBackgroundPictures | List<BackgroundPicture> | Read | Pictures painted over the block’s background and under its border and text, the first on top (see BackgroundPicture). |
TabStops | TabStops? | Read/Write | Tab stops for this fragment (used with #$TAB markers in text). |
IsInLineParagraph | bool | Read/Write | When true, this text fragment renders on the same line as the previous in-line paragraph. |
IsInNewPage | bool | Read/Write | Gets or sets the is in new page. |
IsKeptTogether | bool | Read/Write | Whether the fragment’s lines stay on ONE page: when they do not all fit in the room left on the current page but would fit an empty one, the fragment starts on the next page instead of splitting. |
FootNote | Note? | Read/Write | Optional footnote attached 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 an empty text fragment. |
TextFragment(tabStops: TabStops) | Creates an empty text fragment that aligns its tab characters to the given tab stops; the text is added later through Segments or Text. |
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?) | Creates a text fragment with the given text, an optional bounding rectangle (in points) and an optional text state whose settings are copied onto the fragment. |
Clone() | Shallow copy of the fragment (text + state). |
IsolateTextSegments(startIndex: int, length: int) | Isolate the character range [startIndex, startIndex+length) (startIndex is a 0-based character offset into the fragment’s text) into its own TextSegment(s): the covering segment is split into up to three pieces (before / isolated / after), each inheriting the original segment’s TextState, and the fragment’s Segments collection is rebuilt to reflect the split. |
CloneWithSegments() | Clone the fragment AND its segments. |
BaseParagraph() | Creates a paragraph with default alignment, an empty margin and no hyperlink. |