Class TextFragmentState
Contents
[
Hide
]TextFragmentState class
Represents a text state of a text fragment.
public sealed class TextFragmentState : TextState
Constructors
Name | Description |
---|---|
TextFragmentState(TextFragment) | Initializes new instance of the TextFragmentState object with specified TextFragment object. This TextFragmentState initialization is not supported. TextFragmentState is only available with TextState property. |
Properties
Name | Description |
---|---|
override BackgroundColor { get; set; } | Sets background color of the text, represented by the TextFragment object |
override CharacterSpacing { get; set; } | Gets or sets character spacing of the text, represented by the TextFragment object. |
override CoordinateOrigin { get; set; } | Gets or sets text CoordinateOrigin. If CoordinateOrigin is Descender, the text Y coordinate corresponds to the font’s lowest point. If CoordinateOrigin is BaseLine, the text Y coordinate corresponds to the font’s baseline. The default value is Descender. If the font’s Descent value is too big, text can be rendered higher than other fonts. In this case, CoordinateOrigin BaseLine can be selected for better text rendering. |
DrawTextRectangleBorder { get; set; } | Gets or sets if text rectangle border drawn flag. |
override Font { get; set; } | Gets or sets font of the text, represented by the TextFragment object |
override FontSize { get; set; } | Gets or sets font size of the text, represented by the TextFragment object |
override FontStyle { get; set; } | Sets font style of the text, represented by the TextFragment object |
override ForegroundColor { get; set; } | Gets or sets foreground color of the text, represented by the TextFragment object |
FormattingOptions { get; set; } | Gets or sets formatting options. Setting of the options will be effective in generator scenarios only. |
override HorizontalAlignment { get; set; } | Gets or sets horizontal alignment for the text. |
override HorizontalScaling { get; set; } | Gets or sets horizontal scaling of the text, represented by the TextFragment object. |
override Invisible { get; set; } | Gets or sets invisibility of the text. |
override LineSpacing { get; set; } | Gets or sets line spacing of the text. |
override RenderingMode { get; set; } | Gets or sets rendering mode of the text. |
Rotation { get; set; } | Gets or sets rotation angle in degrees. |
override StrikeOut { get; set; } | Gets or sets strikeout for the text, represented by the TextFragment object |
override StrokingColor { get; set; } | Gets or sets color stroking operations of TextFragment rendering (stroke text, rectangle border) |
override Subscript { get; set; } | Gets or sets subscript of the text, represented by the TextFragment object. |
override Superscript { get; set; } | Gets or sets superscript of the text, represented by the TextFragment object. |
TabStops { get; } | Gets tabstops for the text. |
override Underline { get; set; } | Gets or sets underline for the text, represented by the TextFragment object |
override WordSpacing { get; set; } | Gets or sets word spacing of the text. |
Methods
Name | Description |
---|---|
override ApplyChangesFrom(TextState) | Applies settings from another textState. |
IsFitRectangle(string, Rectangle) | Checks if input string could be placed inside defined rectangle. |
MeasureHeight(char) | Measures character height. (2 methods) |
override MeasureString(string) | Measures the string. |
Fields
Name | Description |
---|---|
readonly TabstopDefaultValue | Default value of tabulation in widths of space character of default font. |
readonly TabTag | You can place this tag in text to declare tabulation. |
Remarks
Provides a way to change following properties of the text: font (Font
property) font size (FontSize
property) font style (FontStyle
property) foreground color (ForegroundColor
property) background color (BackgroundColor
property) Note that changing TextFragmentState
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.
Examples
The example demonstrates how to change text color and font size of the text with TextState
object.
// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object to find all "hello world" text occurrences
TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world");
// Accept the absorber for first page
doc.Pages[1].Accept(absorber);
// Change foreground color of the first text occurrence
absorber.TextFragments[1].TextState.ForegroundColor = Color.FromRgb(System.Drawing.Color.Red);
// Change font size of the first text occurrence
absorber.TextFragments[1].TextState.FontSize = 15;
// Save document
doc.Save(@"D:\Tests\output.pdf");
See Also
- class TextFragmentAbsorber
- class Document
- class TextState
- namespace Aspose.Pdf.Text
- assembly Aspose.PDF