HighlightText

HighlightText(string, Color)

使用指定的颜色高亮显示所有匹配的示例文本。

public void HighlightText(string text, Color highlightColor)
参数类型描述
textString要高亮显示的文本示例。
highlightColorColor用于高亮显示文本的颜色。

另见


HighlightText(string, Color, ITextSearchOptions, IFindResultCallback)

使用指定的颜色高亮显示所有匹配的示例文本。

public void HighlightText(string text, Color highlightColor, ITextSearchOptions options, 
    IFindResultCallback callback)
参数类型描述
textString要高亮显示的文本。
highlightColorColor用于高亮显示文本的颜色。
optionsITextSearchOptions文本搜索选项 ITextSearchOptions
callbackIFindResultCallback接收搜索结果的回调对象 IFindResultCallback

示例

以下代码示例演示如何在 TextFrame 中高亮显示文本。

[C#]
using (Presentation presentation = new Presentation("SomePresentation.pptx"))
{
	// 高亮显示所有单词 'important'
	((AutoShape)presentation.Slides[0].Shapes[0]).TextFrame.HighlightText("important", Color.LightBlue);
	// 高亮显示所有独立的 'the' 出现
	((AutoShape)presentation.Slides[0].Shapes[0]).TextFrame.HighlightText("the", Color.Violet, new TextSearchOptions()
	{ WholeWordsOnly = true }, null);
	presentation.Save("SomePresentation-out2.pptx", SaveFormat.Pptx);
}

另见