You may find yourself in scenarios where you have to save the text of PowerPoint files to a database or some file. Doing this task manually will be time-consuming and less efficient. The better way would be to do the extraction programmatically. To that end, this article will teach you how to extract text from PowerPoint files using C++.
- C++ API to Extract Text from PowerPoint Files
- Extracting Text from a PowerPoint Slide using C++
- Extracting Text from a PowerPoint Presentation using C++
- Get a Free License
C++ API to Extract Text from PowerPoint Files
Aspose.Slides for C++ is a native C++ library that helps you to automate your PowerPoint-related tasks. The API supports creating, reading, and modifying PowerPoint presentations. Furthermore, the API also provides you the ability to extract text from your PowerPoint files. You can either install the API through NuGet or download it directly from the Downloads section.
PM> Install-Package Aspose.Slides.Cpp
Extracting Text from a PowerPoint Slide using C++
The following are the steps to extract text from a PowerPoint slide.
- Firstly, load the PowerPoint presentation using the Presentation class.
- Retrieve the text frames from the slide using SlideUtil::GetAllTextBoxes (System::SharedPtr<IBaseSlide> slide) method.
- Loop through the text frames.
- Within the loop, access the paragraphs using the ITextFrame->get_Paragraphs() method.
- Loop through the paragraphs and access the portions using IParagraph->get_Portions() method.
- Retrieve the text from each portion using IPortion->get_Text() method.
The following is the sample code to extract text from a PowerPoint slide using C++.
Extracting Text from a PowerPoint Presentation using C++
The following are the steps to extract text from a PowerPoint presentation.
- Firstly, load the PowerPoint presentation using the Presentation class.
- Retrieve the text frames from the entire presentation using SlideUtil::GetAllTextFrames (System::SharedPtr<IPresentation> pres, bool withMasters) method.
- Loop through the text frames.
- Within the loop, access the paragraphs using the ITextFrame->get_Paragraphs() method.
- Loop through the paragraphs and access the portions using IParagraph->get_Portions() method.
- Retrieve the text from each portion using IPortion->get_Text() method.
The following is the sample code to extract text from a PowerPoint presentation using C++.
Get a Free License
You can request a free temporary license to try the API without evaluation limitations.
Conclusion
In this article, you have learned how to extract text from PowerPoint files using C++. Specifically, you have learned how to extract text from a particular PowerPoint slide or an entire PowerPoint presentation. Aspose.Slides for C++ provides a bunch of additional features for working with presentations. You can explore the API in detail by visiting the official documentation. In case of any questions, please feel free to contact us on the free support forum.