Search Text in PPTX using Java
Build Java applications that search text in presentation files using server-side APIs.
Search Text in a PPTX Presentation via Java
Using
Aspose.Slides for Java
, you can search text in PPTX presentations. Use the SlideUtil.getAllTextBoxes method to collect text frames and then inspect ITextFrame, IParagraph, and IPortion objects.
Search Text in a PPTX Presentation using Java
Presentation presentation = new Presentation("welcome-to-powerpoint.pptx");
try {
String searchText = "PowerPoint";
for (ISlide slide : presentation.getSlides()) {
ITextFrame[] slideTextFrames = SlideUtil.getAllTextBoxes(slide);
for (ITextFrame textFrame : slideTextFrames) {
for (IParagraph paragraph : textFrame.getParagraphs()) {
for (IPortion portion : paragraph.getPortions()) {
if (portion.getText().contains(searchText)) {
System.out.println(portion.getText());
}
}
}
}
}
} finally {
presentation.dispose();
}How to Search Text in PPTX via Java
Follow these steps to search text in a PPTX presentation.
- Load the PPTX file with the
Presentationclass. - Call the
SlideUtil.getAllTextBoxesmethod to collect text frames from each slide. - Inspect
ITextFrame,IParagraph, andIPortionobjects to find matching text.
Built with Aspose.Slides
Search Text in PPTX Files Online
The free Aspose.Slides Search app is built with Aspose.Slides for Java, the same API as the code above. Open it and see what the API can do with your own PPTX files.
- Runs in your browser, nothing to install.
- See how Aspose.Slides finds text before you write code.
- Search your PPTX file for plain text or regular expressions.
- Download the matches as a text file.
Other Supported Search Formats
Using Java, you can also search text in the following formats.