Skip to content

Instantly share code, notes, and snippets.

@0187773933
Last active February 8, 2023 14:04
Show Gist options
  • Save 0187773933/616f3b648f6270fd2811344df64f2c2b to your computer and use it in GitHub Desktop.
Save 0187773933/616f3b648f6270fd2811344df64f2c2b to your computer and use it in GitHub Desktop.
Prints Slide Titles from a PPTX PowerPoint
#!/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