PPT 主题颜色解释(Theme Color Scheme)

每个 PPTX 文件包含一个主题文件:

复制代码

ppt/theme/theme1.xml

其中定义了 12 种主题颜色:

名称 含义
bg1 Background 1
tx1 Text 1
bg2 Background 2
tx2 Text 2
accent1 强调色 1
accent2 强调色 2
accent3 强调色 3
accent4 强调色 4
accent5 强调色 5
accent6 强调色 6
hlink 超链接颜色
folHlink 访问过的超链接

accent6 就是 PPT 主题的第六个强调色。

不同模板 RGB 会不同。


🔍 如何获取 accent6 的 RGB 颜色?

Python-pptx 不支持直接取 theme 色的 RGB,需要解析 XML:

代码:读取主题颜色(精准版)

复制代码
复制代码
from pptx import Presentation
from lxml import etree

def get_theme_colors(ppt_path):
    prs = Presentation(ppt_path)
    theme_part = prs.part.theme.part
    xml = etree.fromstring(theme_part.blob)

    ns = {"a": "http://schemas.openxmlformats.org/drawingml/2006/main"}

    colors = {}
    scheme_clrs = xml.xpath("//a:themeElements/a:clrScheme/*", namespaces=ns)

    for clr in scheme_clrs:
        name = clr.tag.split("}")[-1]  # accent1, accent2...
        rgb = None

        srgbClr = clr.find("a:srgbClr", ns)
        if srgbClr is not None:
            rgb = srgbClr.get("val")

        colors[name] = rgb

    return colors

print(get_theme_colors("你的PPT路径.pptx"))

返回示例:

复制代码
复制代码
{
  'accent1': '4472C4',
  'accent6': '70AD47',
  'bg1': 'FFFFFF',
  ...
}
相关推荐
E_ICEBLUE7 小时前
PPT 批量转图片:在 Web 预览中实现翻页效果(C#/VB.NET)
c#·powerpoint·svg
2501_930707781 天前
使用 C# .NET 从 PowerPoint 演示文稿中提取背景图片
c#·powerpoint·.net
小真zzz2 天前
2026年2月:AI模板生成PPT的深度解析:ChatPPT如何重新定义行业标准
人工智能·powerpoint·ppt·chatppt·aippt
wasp5202 天前
Banana Slides 深度解析:PPT 生成引擎与逆向工程机制
powerpoint
cooldream20093 天前
本科毕业设计开题报告系列之十一:开题答辩 PPT 怎么做?
毕业设计·powerpoint·开题报告
cool_switch4 天前
效率革新:深度体验一款面向开发者的“一站式”AI PPT生成方案
人工智能·powerpoint
名字不好奇5 天前
职场PPT之道
powerpoint
大模型RAG和Agent技术实践7 天前
突破RAG边界:构建能“读懂“PPT逻辑与图文的智能问答系统实战(附完整源代码)
大模型·powerpoint·智能问答·rag
盘古工具7 天前
PPT怎么放映?新手也能快速上手
powerpoint
取个鸣字真的难7 天前
简单快速的用 Claude Code 帮你创建 PPT 生成 Skills
vscode·powerpoint·ai编程