PNG
JPG
BMP
TIFF
PPTX
Search PPTX Formats in C#
Native and high performance PPTX document search using server-side Aspose.Slides for .NET APIs, without the use of any software like Microsoft or Adobe PDF.
Search PPTX File Using C#
In order to search PPTX file, we’ll use
API which is a feature-rich, powerful and easy to use Microsoft PowerPoint files searching API for C# platform. Open
package manager, search for Aspose.Slides and install. You may also use the following command from the Package Manager Console.
Command
PM> Install-Package Aspose.Slides.NET
How to Search PPTX Files in C#
A basic document search with Aspose.Slides for .NET APIs can be done with just few lines of code.
Load PPTX file.
Get all text boxes in presentation
Search the text.
Replace the text.
Write the PPTX presentation.
System Requirements
Our APIs are supported on all major platforms and Operating Systems. Before executing the code below, please make sure that you have the following prerequisites on your system.
- Microsoft Windows or a compatible OS with .NET Framework, .NET Core, Windows Azure, Mono or Xamarin Platforms
- Development environment like Microsoft Visual Studio
- Aspose.Slides for .NET DLL referenced in your project - Install from NuGet using the Download button above
Search PPTX Files - C#
Presentation pres = new Presentation("filetobesearched.pptx");
//Get all text boxes in the presentation
ITextFrame[] tb = SlideUtil.GetAllTextBoxes(pres.Slides[0]);
for (int i = 0; i < tb.Length; i++)
foreach (Paragraph para in tb[i].Paragraphs)
foreach (Portion port in para.Portions)
//Search text to be replaced
if (port.Text.Contains(strToFind))
//Replace exisitng text with the new text
{
string str = port.Text;
int idx = str.IndexOf(strToFind);
string strStartText = str.Substring(0, idx);
string strEndText = str.Substring(idx + strToFind.Length, str.Length - 1 - (idx + strToFind.Length - 1));
port.Text = strStartText + strToReplaceWith + strEndText;
}
pres.Save("filetobesearched.pptx",Aspose.Slides.Export.SaveFormat.Pptx);
Slides API can be used to read, write, manipulate and convert Microsoft PowerPoint documents to PDF, XPS, HTML, TIFF, ODP and various other formats. One can create new files from scratch and save those in the relevant supported formats. Aspose.Slides is a standalone API for creating, parsing or manipulating presentations, slides and elements and it does not depend on any software like Microsoft or OpenOffice.