Last active
February 8, 2023 14:04
-
-
Save 0187773933/616f3b648f6270fd2811344df64f2c2b to your computer and use it in GitHub Desktop.
Prints Slide Titles from a PPTX PowerPoint
This file contains hidden or 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
#!/usr/bin/env python3 | |
import sys | |
import collections # cause of yew python 3.10 | |
import collections.abc # cause of yew python 3.10 | |
import pptx # python-pptx | |
def get_highest_shape_object( slide ): | |
potentials = [] | |
for index , shape in enumerate( slide.shapes ): | |
potentials.append( [ shape.top , shape ] ) | |
sorted_potentials = sorted( potentials , key=lambda x: x[0] ) | |
return sorted_potentials[ 0 ][ 1 ] | |
if __name__ == "__main__": | |
power_point = pptx.Presentation( sys.argv[ 1 ] ) | |
for index , slide in enumerate( power_point.slides ): | |
most_likely_title_shape = get_highest_shape_object( slide ) | |
if hasattr( most_likely_title_shape , "text" ): | |
print( f"{index+1} === {most_likely_title_shape.text}" ) | |
else: | |
print( f"{index+1} === Blank" ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment