Extract Text from PPTX Presentations with Python
Build Python applications that extract text and text formatting details from PowerPoint presentations with Aspose.Slides.
Extract Text from a PPTX Presentation with Python
Aspose.Slides for Python via .NET
provides the
get_all_text_frames
static method on SlideUtil. It returns the TextFrame objects from an entire presentation and can include text from master slides. The following example extracts text and related font details from a PPTX presentation.
Extract Text from a PPTX Presentation - Python
include_master_slides = True
with slides.Presentation("presentation.pptx") as presentation:
text_frames = slides.util.SlideUtil.get_all_text_frames(presentation, include_master_slides)
for text_frame in text_frames:
for paragraph in text_frame.paragraphs:
for portion in paragraph.portions:
print(portion.text)
font_height = portion.portion_format.font_height
print(font_height)
latin_font = portion.portion_format.latin_font
if latin_font is not None:
print(latin_font.font_name)How to Extract Text from PPTX with Python
Follow these steps to extract text from a PPTX file.
- Open the PPTX file with
Presentation. - Call
SlideUtil.get_all_text_framesand specify whether to include master slides. - Iterate through the returned
TextFrameobjects. - Iterate through each text frame’s
paragraphscollection. - Iterate through each paragraph’s
portionscollection. - Read the current portion’s
textand formatting properties.
Built with Aspose.Slides
Extract Text and Images Online
The free Aspose.Slides Parser app is built with Aspose.Slides for Python via .NET, the same API as the code above. Open it and see what the API can do with your own PPTX files.
- Runs in your browser, nothing to install.
- See how Aspose.Slides reads your files before you write code.
- Upload your PPTX file and get its text and images.
- Download everything as one ZIP archive.
Other Supported Parsing Formats
Use Python to extract text from other supported presentation formats.