TextState
概述
TextState 是 Aspose.PDF FOSS 中用于 .NET 的类。
文本格式化状态。
此类提供 10 个用于在 .NET 程序中处理 TextState 对象的方法。可用的方法包括:ApplyChangesFrom、MeasureHeight、MeasureString、TextState。在安装了 Aspose.PDF FOSS for .NET 包后,所有公共成员对任何 .NET 应用程序均可访问。属性有:BackgroundColor、CharacterSpacing、CoordinateOrigin、Font、FontData、FontName,以及另外 26 项。
属性
| 名称 | 类型 | 访问 | 描述 |
|---|---|---|---|
FontName | string? | 读写 | 获取或设置字体名称。 |
TextXIndent | float | 读取 | 此状态所属文本在页面上的起始 X(点)位置。 |
TextHeight | float | 读取 | 文本高度(点):(上升 + |
FontSize | float | 读写 | 获取或设置字体大小。 |
ForegroundColor | Color? | 读写 | 获取或设置前景颜色。 |
StrokingColor | Color? | 读写 | 文本的描边(轮廓)颜色。 |
CoordinateOrigin | CoordinateOrigin | 读写 | 文本定位是否将 Y 视为基线或下延线。 |
BackgroundColor | Color? | 读写 | 获取或设置背景颜色。 |
IsBold | bool | 读写 | 字体是否为粗体。 |
IsItalic | bool | 读写 | 字体是否为斜体。 |
FontStyle | FontStyles | 读写 | 字体样式标志(粗体、斜体等)。 |
Underline | bool | 读写 | 文本是否带下划线(IsUnderline 的别名)。 |
IsUnderline | bool | 读写 | 文本是否带下划线。 |
IsStrikeOut | bool | 读写 | 文本是否带删除线。 |
StrikeOut | bool | 读写 | 对 IsStrikeOut 的别名。 |
IsSuperscript | bool | 读写 | 文本是否为上标。 |
Superscript | bool | 读写 | 对 IsSuperscript 的别名。 |
IsSubscript | bool | 读写 | 文本是否为下标。 |
Subscript | bool | 读写 | IsSubscript 的别名。 |
CharacterSpacing | float | 读写 | 以文本空间单位计的字符间距。 |
WordSpacing | float | 读写 | 文字间距(以文本空间单位计)。 |
HorizontalScaling | float | 读写 | 水平缩放百分比(默认 100)。 |
LineSpacing | float | 读写 | 行间距(leading)以文本空间单位计。 |
TabTag | string | 读取 | 在渲染后的文本中插入的字符串标记,用于代替制表符。 |
HorizontalAlignment | HorizontalAlignment | 读写 | 文本的水平对齐。 |
RenderingMode | TextRenderingMode | 读写 | 文本渲染模式(Tr 运算符)。 |
Invisible | bool | 读写 | 此文本片段是否不可见:渲染模式 3,或文本被后续不透明填充矩形完全覆盖(隐藏方式:编辑遮蔽式覆盖文本报告为 Invisible,而其 RenderingMode 保持 FillText)。 |
TextRise | double | 读写 | 文本上升(上标/下标偏移)。 |
Rotation | double | 读写 | 文本旋转角度(单位:度)。 |
Font | Font? | 读写 | 获取或设置字体。 |
FontData | FontData? | 读写 | 用于嵌入的外部字体数据(通过 FontRepository.OpenFont 设置)。 |
FormattingOptions | TextFormattingOptions | 读写 | 文本格式化选项(WordWrapMode、LineSpacingMode 等)。 |
方法
| 签名 | 描述 |
|---|---|
TextState() | 在此 TextState 实例上调用 TextState。 |
TextState(fontSize: double) | 在此 TextState 实例上调用 TextState(fontSize)。 |
TextState(fontFamily: string) | 在此 TextState 实例上调用 TextState(fontFamily)。 |
TextState(fontFamily: string, fontSize: double) | 在此 TextState 实例上调用 TextState(fontFamily, fontSize)。 |
TextState(fontFamily: string, bold: bool, italic: bool) | 在此 TextState 实例上调用 TextState(fontFamily, bold, italic)。 |
TextState(foregroundColor: System.Drawing.Color) | 在此 TextState 实例上调用 TextState(foregroundColor)。 |
TextState(foregroundColor: System.Drawing.Color, fontSize: double) | 在此 TextState 实例上调用 TextState(foregroundColor, fontSize)。 |
MeasureString(str: string) | 当前字体/大小下的文本宽度粗略估计。 |
MeasureHeight(character: char) | 当前字体/字号下字符的高度(单位:点)——即字形自身的边界框高度 (yMax − yMin),映射到文本空间为 height × FontSize / 1000。 |
ApplyChangesFrom(textState: TextState) | 将 other 中的每个公共格式属性复制到此 state(保持所有者链接完整)。 |