Search code examples
pythonphppowerpointpython-pptx

Extract presenter notes from PPTx file (powerpoint)


Is there a solution in python or php that will allow me to get the presenter notes from each slide in a power point file?

Thank you


Solution

  • You can use python-pptx.

    pip install python-pptx

    You can do the following to extract presenter notes:

    import collections 
    import collections.abc
    from pptx import Presentation
    
    file = 'path/to/presentation.pptx'
    
    ppt=Presentation(file)
    
    notes = []
    
    for page, slide in enumerate(ppt.slides):
        # this is the notes that doesn't appear on the ppt slide,
        # but really the 'presenter' note. 
        textNote = slide.notes_slide.notes_text_frame.text
        notes.append((page,textNote)) 
    
    print(notes)
    
    

    The notes list will contain all notes on different pages.

    If you want to extract text content on a slide, you need to do this:

    for page, slide in enumerate(ppt.slides):
        temp = []
        for shape in slide.shapes:
            # this will extract all text in text boxes on the slide.
            if shape.has_text_frame and shape.text.strip():
                temp.append(shape.text)
        notes.append((page,temp))