This demo uses the DevExpress Presentation API to find and replace text in a presentation. You can use the predefined sample file or upload your own presentation. To do the latter, select Upload a File in the file selection drop-down menu.
Select the operation mode (replace, remove, or highlight), specify the text to find, and the replacement text, if required. Use the Modify Presentation and Save to... dropdown button to select the output format, update the presentation, and download the result.
using DevExpress.Docs;
using DevExpress.Docs.Presentation;
Stream FindReplacePresentationText(Stream inputStream, FindReplaceActionType actionType, string findText, string replaceText, Color highlightColor, DocumentFormat outputFormat) {
var presentation = new Presentation(inputStream);
var searchResult = presentation.FindText(findText);
switch(actionType) {
case FindReplaceActionType.Replace:
presentation.ReplaceText(searchResult, replaceText);
break;
case FindReplaceActionType.Remove:
presentation.RemoveText(searchResult);
break;
case FindReplaceActionType.Highlight:
presentation.ModifyTextProperties(searchResult, new TextProperties() { HighlightColor = new OfficeColor(highlightColor) });
break;
}
var outputStream = new MemoryStream();
presentation.SaveDocument(outputStream, outputFormat);
outputStream.Position = 0;
return outputStream;
}