Learn how to extract text from PowerPoint file in Python: https://blog.aspose.com/2022/01/20/extract-text-from-powerpoint-files-in-python/
Last active
June 1, 2022 08:34
-
-
Save aspose-com-gists/58a8371b5bb52eff43b8bd441c67e412 to your computer and use it in GitHub Desktop.
Extract Text from PowerPoint Files in Python
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
import aspose.slides as slides | |
# Get all the text from presentation | |
text = slides.PresentationFactory().get_presentation_text("presentation.pptx", slides.TextExtractionArrangingMode.UNARRANGED) | |
# Load the presentation to get slide count | |
with slides.Presentation("presentation.pptx") as ppt: | |
# Loop through slides in the presentation | |
for index in range(ppt.slides.length): | |
# Print text of desired sections such as slide's text, layout text, notes, etc. | |
print(text.slides_text[index].text) | |
print(text.slides_text[index].layout_text) | |
print(text.slides_text[index].master_text) | |
print(text.slides_text[index].notes_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
import aspose.slides as slides | |
# Get all the text from presentation | |
text = slides.PresentationFactory().get_presentation_text("presentation.pptx", slides.TextExtractionArrangingMode.UNARRANGED) | |
# Print text of the desired slide using its index | |
print(text.slides_text[0].text) | |
print(text.slides_text[0].layout_text) | |
print(text.slides_text[0].master_text) | |
print(text.slides_text[0].notes_text) |
@MalekBezzina,
I have not managed to reproduce the error you are experiencing. That code works fine on my end. Please share the following data and information:
- presentation file
- OS version where the code was executed
- Python version you used
- Aspose.Slides version you used
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tried to run the first code and got this error;
RuntimeError: Proxy error(KeyNotFoundException): The given key '11' was not present in the dictionary.