Last active
April 9, 2021 11:55
-
-
Save aspose-com-gists/c6cba3880eb328b23824b943bc37a45e to your computer and use it in GitHub Desktop.
Extract Text from PowerPoint Files using C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Examples for Extracting Text from PowerPoint Files using C++ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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()); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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