HighlightText

HighlightText(string, Color)

使用指定颜色突出显示样本文本的所有匹配项。

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

示例

以下代码示例演示如何在PowerPoint演示文稿中突出显示文本。

[C#]
using (Presentation presentation = new Presentation("SomePresentation.pptx"))
{
	// 突出显示所有单独的'the'出现
	presentation.HighlightText("the", Color.Violet);
	presentation.Save("SomePresentation-out2.pptx", SaveFormat.Pptx);
}

另请参见


HighlightText(string, Color, ITextSearchOptions, IFindResultCallback)

使用指定颜色突出显示样本文本的所有匹配项。

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

示例

以下代码示例演示如何在PowerPoint演示文稿中突出显示文本。

[C#]
using (Presentation presentation = new Presentation("SomePresentation.pptx"))
{
	// 突出显示所有单独的'the'出现
	presentation.HighlightText("the", Color.Violet, new TextSearchOptions() {WholeWordsOnly = true}, null);
	presentation.Save("SomePresentation-out2.pptx", SaveFormat.Pptx);
}

另请参见