from pptx import Presentationprs = Presentation()slide = prs.slides.add_slide(prs.slide_layouts[0])# Add notes to the slidenotes_slide = slide.notes_slidetext_frame = notes_slide.notes_text_frametext_frame.text = "This is my speaker note for this slide."prs.save('presentation_with_notes.pptx')
from pptx import Presentationprs = Presentation('presentation.pptx')slide = prs.slides[0]# Check without creating notes slideif slide.has_notes_slide: print("Slide has notes") notes_slide = slide.notes_slide text_frame = notes_slide.notes_text_frame print(f"Notes: {text_frame.text}")else: print("Slide has no notes")
Use .has_notes_slide to check for notes without creating a notes slide. Accessing .notes_slide directly will create a notes slide if one doesn’t exist.
from pptx import Presentationprs = Presentation('presentation.pptx')slide = prs.slides[0]if slide.has_notes_slide: notes_slide = slide.notes_slide # Iterate through all shapes for shape in notes_slide.shapes: print(f"Shape: {shape.name}") # Check if it's a placeholder if shape.is_placeholder: ph_type = shape.placeholder_format.type print(f" Placeholder type: {ph_type}")
from pptx import Presentationprs = Presentation('template.pptx')# Speaker notes for each slidenotes_list = [ "Welcome the audience and introduce the topic", "Explain the main problem we're solving", "Walk through the solution architecture", "Discuss implementation timeline", "Thank the audience and open for Q&A"]# Add notes to each slidefor slide, note_text in zip(prs.slides, notes_list): notes_slide = slide.notes_slide text_frame = notes_slide.notes_text_frame text_frame.text = note_textprs.save('presentation_with_notes.pptx')
from pptx import Presentationprs = Presentation('presentation.pptx')# Export all notes to a text filewith open('speaker_notes.txt', 'w', encoding='utf-8') as f: for slide_num, slide in enumerate(prs.slides, start=1): f.write(f"Slide {slide_num}\n") f.write("=" * 50 + "\n") if slide.has_notes_slide: notes_slide = slide.notes_slide text_frame = notes_slide.notes_text_frame f.write(text_frame.text + "\n") else: f.write("(No notes)\n") f.write("\n")print("Notes exported to speaker_notes.txt")