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',
  ...
}
相关推荐
带土15 天前
11. MathType卸载后PowerPoint启动时无显示法加载MathType公式编辑器加载项
powerpoint
m5655bj5 天前
通过 C# 将 PPT 文档转换为 HTML 格式
c#·html·powerpoint
道纪书生6 天前
解决报错:很抱歉,powerpoint/word/excel遇到错误,使其无法正常工作......
word·powerpoint·excel
johnny2336 天前
PPT生成工具
powerpoint
小真zzz10 天前
ChatPPT Nano Banana Pro · Magic模式深度解析 ——重新定义“所想即所得”的PPT智能编辑
人工智能·ai·powerpoint·ppt·aippt
王解12 天前
AI生成PPT的技术演进:从智能填充到认知增强
人工智能·powerpoint
2501_9469614712 天前
PPT课件怎么做?2026最新版制作流程与免费资源汇总
powerpoint
github.com/starRTC12 天前
Claude Code中英文系列教程35:通过API使用Skills创建ppt,word文档和pdf
pdf·word·powerpoint·ai编程
琛説14 天前
⚡PitchPPT:将PPT导出为高清全图PPT,并控制PPT文件大小在固定MB/GB以内【解析算法原理 · 作者谈】
windows·python·算法·github·powerpoint