运行时依赖
安装命令
点击复制技能文档
PPT 生成器
专业PPT生成器,创建可编辑、排版精美、多风格的PowerPoint演示文稿。
Features 📊 可编辑PPTX: 标准Office格式,可二次编辑 🎨 多种风格: 商务、学术、创意、简约 📐 精美排版: 专业布局,字体层次清晰 📈 图表支持: 柱状图、折线图、饼图 🖼️ 图片支持: 插入图片,自动排版 📝 专业模板: 10+预制模板 支持的风格 风格 适用场景 特点 商务蓝 商业汇报 专业、稳重 学术白 学术论文 简洁、规范 创意紫 创意展示 时尚、活力 科技深 技术分享 现代、高端 极简灰 通用场景 简约、百搭 使用方式 User: "帮我做一个关于AI发展的PPT" User: "生成商务风格的项目汇报PPT" User: "做一个学术论文答辩PPT"
Python代码实现 from pptx 导入 Presentation from pptx.util 导入 Inches, Pt, Emu from pptx.dml.color 导入 RGBColor from pptx.enum.text 导入 PP_ALIGN, MSO_ANCHOR from pptx.enum.shapes 导入 MSO_SHAPE
class PPT生成器: def __init__(self, style='business_blue'): self.prs = Presentation() self.style = style self.colors = self._获取_colors(style) self.fonts = self._获取_fonts() def _获取_colors(self, style): """获取配色方案""" schemes = { 'business_blue': { 'primary': RGBColor(30, 60, 114), 'secondary': RGBColor(70, 130, 180), 'accent': RGBColor(255, 193, 7), 'text': RGBColor(51, 51, 51), 'bg': RGBColor(255, 255, 255) }, 'academic_white': { 'primary': RGBColor(0, 51, 102), 'secondary': RGBColor(102, 102, 102), 'accent': RGBColor(204, 0, 0), 'text': RGBColor(51, 51, 51), 'bg': RGBColor(255, 255, 255) }, 'creative_purple': { 'primary': RGBColor(102, 45, 140), 'secondary': RGBColor(155, 89, 182), 'accent': RGBColor(241, 196, 15), 'text': RGBColor(51, 51, 51), 'bg': RGBColor(248, 248, 255) }, 'tech_dark': { 'primary': RGBColor(30, 30, 30), 'secondary': RGBColor(60, 60, 60), 'accent': RGBColor(0, 200, 150), 'text': RGBColor(240, 240, 240), 'bg': RGBColor(20, 20, 25) }, 'minimal_gray': { 'primary': RGBColor(80, 80, 80), 'secondary': RGBColor(150, 150, 150), 'accent': RGBColor(0, 120, 215), 'text': RGBColor(51, 51, 51), 'bg': RGBColor(250, 250, 250) } } return schemes.获取(style, schemes['business_blue']) def _获取_fonts(self): """获取字体配置""" return { 'title': 'Arial', 'body': 'Arial', 'chinese': 'Microsoft YaHei' } def 添加_title_slide(self, title, subtitle=''): """添加封面页""" slide = self.prs.slides.添加_slide(self.prs.slide_layouts[6]) # 背景色 self._设置_slide_bg(slide, self.colors['bg']) # 标题 left, top, width, height = Inches(1), Inches(2), Inches(8), Inches(2) txBox = slide.shapes.添加_textbox(left, top, width, height) tf = txBox.text_frame tf.word_wrap = True p = tf.paragraphs[0] p.text = title p.font.size = Pt(44) p.font.bold = True p.font.color.rgb = self.colors['primary'] p.alignment = PP_ALIGN.CENTER # 副标题 if subtitle: p2 = tf.添加_paragraph() p2.text = subtitle p2.font.size = Pt(20) p2.font.color.rgb = self.colors['secondary'] p2.alignment = PP_ALIGN.CENTER p2.space_before = Pt(20) return slide def 添加_content_slide(self, title, bullets, layout='left'): """添加内容页""" slide = self.prs.slides.添加_slide(self.prs.slide_layouts[6]) # 背景色 self._设置_slide_bg(slide, self.colors['bg']) # 标题栏 self._添加_title_bar(slide, title) # 内容区域 left, top, width, height = Inches(0.8), Inches(1.5), Inches(8.4), Inches(5) txBox = slide.shapes.添加_textbox(left, top, width, height) tf = txBox.text_frame tf.word_wrap = True for i, bullet in enumerate(bullets): p = tf.paragraphs[0] if i == 0 else tf.添加_paragraph() p.text = f"• {bullet}" p.font.size = Pt(18) p.font.color.rgb = self.colors['text'] p.space_after = Pt(12) return slide def 添加_two_column_slide(self, title, left_content, right_content): """添加双栏内容页""" slide = self.prs.slides.添加_slide(self.prs.slide_layouts[6]) self._设置_slide_bg(slide, self.colors['bg']) self._添加_title_bar(slide, title) # 左栏 left_box = slide.shapes.添加_textbox(Inches(0.5), Inches(1.5), Inches(4.5), Inches(5)) left_tf = left_box.text_frame left_tf.word_wrap = True for i, item in enumerate(left_content): p = left_tf.paragraphs[0] if i == 0 else left_tf.添加_paragraph() p.text = f"• {item}" p.font.size =