TextState
TextFragment.TextState property
获取或设置文本的文本状态TextFragment
对象代表.
public TextFragmentState TextState { get; }
评论
提供更改文本以下属性的方法: Font FontSize FontStyle ForegroundColor BackgroundColor
例子
该示例演示了如何更改文本的颜色和字体大小TextState
对象.
// 打开文档
Document doc = new Document(@"D:\Tests\input.pdf");
// 创建 TextFragmentAbsorber 对象以查找所有“hello world”文本出现
TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world");
// 接受第一页的吸收器
doc.Pages[1].Accept(absorber);
// 更改第一个文本出现的前景色
absorber.TextFragments[1].TextState.ForegroundColor = Color.FromRgb(System.Drawing.Color.Red);
// 更改第一个文本出现的字体大小
absorber.TextFragments[1].TextState.FontSize = 15;
// 保存文档
doc.Save(@"D:\Tests\output.pdf");
也可以看看
- class TextFragmentAbsorber
- class Document
- class TextFragmentState
- class TextFragment
- 命名空间 Aspose.Pdf.Text
- 部件 Aspose.PDF