C#: Online Guide
How To: powerpoint SDK
Text Search
  |  
Home ›› XDoc.PowerPoint ›› C# PowerPoint: Text Search

C# PowerPoint - Search and Find Text in PowerPoint


Learn How to Search Text in PDF Document and Obtain Text Content and Location Information




Overview



RasterEdge XDoc.PowerPoint for .NET allows C# programmers to integrate text search functionality into their PowerPoint document management application. To be specific, using mature C#.NET APIs, programmers can achieve following aspects.


Related .net document control helps:
c# asp.net dicom document viewer: ASP.NET Dicom Document Viewer Control: view, annotate dicom imaging files online in ASP.NET
c# asp.net webforms document viewer: ASP.NET WebForms application document viewer control: view, annotate, redact, convert files online in ASP.NET
c# asp.net powerpoint document viewer: ASP.NET PowerPoint Document Viewer Control: view pptx files online in C# using ASP.NET
c# asp.net tiff document viewer: ASP.NET Tiff Document Viewer: view, annotate Tiff files in HTML using C# Control
asp.net convert pdf using c#: ASP.NET Convert PDF Control: Convert, export PDF to Word, HTML, Tiff files in C# ASP.NET
asp.net azure pdf editor using c#: ASP.NET Azure PDF Editor Control: view, edit, annotate, redact PDF files online
c# asp.net excel document viewer: ASP.NET Excel Document Viewer in C# Control: view office excel files online in ASP.NET web applications


Easy to search and find text content and get its location details


Allow to search defined PowerPoint file page or the whole document


Support search PowerPoint file with various search options, like whole PowerPoint, ignore case, match string, etc.




C# PDF: Example of Finding Text



Add references:


  RasterEdge.Imaging.Basic.dll


  RasterEdge.XDoc.PowerPoint.dll


Using namespace:


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.PowerPoint;


  using RasterEdge.Imaging.Basic.TextSearch;


The following C# coding example illustrates how to perform PowerPoint text searching function in your .NET project, including setting search option, creating search result, and saving the result.




internal static void TestSearch(String fileName, String matchString, String cacheFile)
{

// Set search options.
RESearchOption option = new RESearchOption();
option.SetMatchString(matchString);
option.WholeWord = true;
option.IgnoreCase = true;
option.ContextExpansion = 30;

// It will create a cach file if your PDF document is never been searched before. 
if (!File.Exists(fileName))
{
BaseDocument document = getBaseDocument(TestFilePath.InputFilePath + fileName);
document.CacheSearchInfo(TestFilePath.InputFilePath + cacheFile);
}

// Create search result.
SearchResult sResult = new SearchResult();

// Search and store the result in the entity of search structure.
BaseDocument.Search(TestFilePath.InputFilePath + cacheFile, option, sResult);
}

private static BaseDocument getBaseDocument(String filePath)
{
BaseDocument document = null;
if (filePath.EndsWith(".pdf"))
document = new PDFDocument(filePath);
else if (filePath.EndsWith(".docx"))
document = new DOCXDocument(filePath);
else if (filePath.EndsWith(".xlsx"))
document = new XLSXDocument(filePath);
else if (filePath.EndsWith(".pptx"))
document = new PPTXDocument(filePath);
else
{}
return document;
}