Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active June 1, 2022 08:34
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/58a8371b5bb52eff43b8bd441c67e412 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/58a8371b5bb52eff43b8bd441c67e412 to your computer and use it in GitHub Desktop.
Extract Text from PowerPoint Files in Python
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)
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
Copy link

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.

@andreypotapovaspose
Copy link

@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