agentleFS
Marnie0415Marnie0415/pi-skills/pptx-processing/SKILL.md

pptx-processing

Skill1 starsChanged 5 months agoMITView on GitHub

Create, read, and modify Microsoft PowerPoint (.pptx) presentations. Use when the user needs to generate slide decks, extract content from presentations, edit slides programmatically, or automate PowerPoint tasks.

  • Installs packages

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

Files
SKILL.md

PPTX 演示文稿处理 Skill

在 Termux Android 上使用纯 Python 工具处理 .pptx 文件。

可用工具

优先方案: python-pptx

pip install python-pptx

备用方案: 解压 + XML 编辑

.pptx 本质也是 ZIP 包:

unzip -o file.pptx -d pptx_unpacked/
# 编辑 pptx_unpacked/ppt/slides/slide1.xml 等
cd pptx_unpacked && zip -r ../modified.pptx *

常见操作

1. 创建新的 PPTX 文件

from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.enum.text import PP_ALIGN

prs = Presentation()
slide_layout = prs.slide_layouts[1]  # 标题和内容布局
slide = prs.slides.add_slide(slide_layout)
title = slide.shapes.title
title.text = "演示标题"

# 添加正文
content = slide.placeholders[1]
content.text = "要点 1\n要点 2\n要点 3"

prs.save('presentation.pptx')

2. 添加带格式的文本框

from pptx.util import Inches, Pt
from pptx.dml.color import RGBColor

slide = prs.slides.add_slide(prs.slide_layouts[6])  # 空白布局
left = Inches(1); top = Inches(1); width = Inches(8); height = Inches(1)
txBox = slide.shapes.add_textbox(left, top, width, height)
tf = txBox.text_frame
p = tf.paragraphs[0]
p.text = "红色大字标题"
p.font.size = Pt(36)
p.font.color.rgb = RGBColor(0xFF, 0x00, 0x00)

3. 提取所有幻灯片文字

prs = Presentation('input.pptx')
for i, slide in enumerate(prs.slides, 1):
    print(f"--- Slide {i} ---")
    for shape in slide.shapes:
        if shape.has_text_frame:
            for para in shape.text_frame.paragraphs:
                print(para.text)

4. 添加图片到幻灯片

from pptx.util import Inches
slide = prs.slides.add_slide(prs.slide_layouts[6])
pic = slide.shapes.add_picture('chart.png', Inches(1), Inches(1), width=Inches(6))

5. 复制幻灯片(跨文件)

# python-pptx 不直接支持跨文件复制,用 ZIP 操作:
# 1. 解压两个文件
# 2. 复制 ppt/slides/slideN.xml + 对应的 _rels
# 3. 更新 [Content_Types].xml + ppt/presentation.xml

注意事项

  • 📐 slide_layouts 索引因模板而异,打印查看 prs.slide_layouts 列表确认
  • ⚠️ python-pptx 的文本框定位使用 Inches/Emu 单位
  • 🔄 中文内容需要嵌入字体才能在不同设备上正确显示
  • 📏 图表数据用外部生成图片后插入,不要尝试在 PPTX 里做复杂图表
  • 💾 操作前先备份原文件

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.