The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

Build a slide presentation generator

Here is a Python-based Slide Presentation Generator that creates a PowerPoint file from text input. It uses the python-pptx library, which is well-suited for building and customizing .pptx slide decks programmatically.


🔧 Requirements

You need to install the python-pptx library first:

bash
pip install python-pptx

📜 Slide Generator Code

python
from pptx import Presentation from pptx.util import Inches, Pt from pptx.enum.shapes import MSO_SHAPE from pptx.dml.color import RGBColor def create_slide(pres, title, content): slide_layout = pres.slide_layouts[1] # Title and Content slide = pres.slides.add_slide(slide_layout) title_placeholder = slide.shapes.title content_placeholder = slide.placeholders[1] title_placeholder.text = title content_placeholder.text = content def generate_presentation(title, slides, filename="presentation.pptx"): prs = Presentation() # Title Slide title_slide_layout = prs.slide_layouts[0] slide = prs.slides.add_slide(title_slide_layout) slide.shapes.title.text = title slide.placeholders[1].text = "Generated by Slide Generator" # Content Slides for slide_info in slides: slide_title = slide_info.get("title", "Slide") slide_content = slide_info.get("content", "") create_slide(prs, slide_title, slide_content) prs.save(filename) print(f"Presentation saved as '{filename}'.") # Example Usage if __name__ == "__main__": presentation_title = "Benefits of Remote Work" slide_data = [ {"title": "Introduction", "content": "Remote work allows flexibility and comfort for employees."}, {"title": "Cost Savings", "content": "Companies save on infrastructure and utilities."}, {"title": "Work-Life Balance", "content": "Employees can better manage personal responsibilities."}, {"title": "Productivity", "content": "Many studies show increased output from remote workers."}, {"title": "Conclusion", "content": "Remote work is becoming a long-term strategy for many organizations."}, ] generate_presentation(presentation_title, slide_data)

✅ Features

  • Automatically creates a title slide

  • Adds multiple content slides based on a list of dictionaries

  • Editable slide titles and contents

  • Generates .pptx file compatible with Microsoft PowerPoint and Google Slides


Let me know if you want:

  • Support for bullet points, images, or charts

  • Export to PDF

  • A web-based UI (Flask or Streamlit interface)

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About