Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/c6cba3880eb328b23824b943bc37a45e to your computer and use it in GitHub Desktop.
Save aspose-com-gists/c6cba3880eb328b23824b943bc37a45e to your computer and use it in GitHub Desktop.
Extract Text from PowerPoint Files using C++
Examples for Extracting Text from PowerPoint Files using C++
// Sample file path
const String sourceFilePath = u"SourceDirectory\\SamplePresentation.pptx";
// Load the Presentation file
SharedPtr<Presentation> presentation = MakeObject<Presentation>(sourceFilePath);
// Get an Array of ITextFrame objects from all slides in the Presentation
System::ArrayPtr<SharedPtr<ITextFrame>> textFramesPresentation = SlideUtil::GetAllTextFrames(presentation, true);
// Loop through the Array of TextFrames
for (int i = 0; i < textFramesPresentation->get_Length(); i++)
{
// Loop through paragraphs in current ITextFrame
for (SharedPtr<IParagraph> paragraph : textFramesPresentation[i]->get_Paragraphs())
{
// Loop through portions in the current IParagraph
for (SharedPtr<IPortion> portion : paragraph->get_Portions())
{
// Display text
Console::WriteLine(portion->get_Text());
}
}
}
// Sample file path
const String sourceFilePath = u"SourceDirectory\\SamplePresentation.pptx";
// Load the Presentation file
SharedPtr<Presentation> presentation = MakeObject<Presentation>(sourceFilePath);
// Get an Array of ITextFrame objects from the first slide
System::ArrayPtr<SharedPtr<ITextFrame>> textFramesSlideOne = SlideUtil::GetAllTextBoxes(presentation->get_Slides()->idx_get(0));
// Loop through the Array of TextFrames
for (int i = 0; i < textFramesSlideOne->get_Length(); i++)
{
// Loop through paragraphs in current ITextFrame
for (SharedPtr<IParagraph> paragraph : textFramesSlideOne[i]->get_Paragraphs())
{
// Loop through portions in the current IParagraph
for (SharedPtr<IPortion> portion : paragraph->get_Portions())
{
// Display text
Console::WriteLine(portion->get_Text());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment