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',
  ...
}
相关推荐
dagouaofei1 天前
AI 生成 2026 年工作计划 PPT,内容质量差异在哪里
人工智能·python·powerpoint
ai_top_trends1 天前
2026 年工作计划汇报 PPT:AI 生成方案实测对比
人工智能·python·powerpoint
dagouaofei1 天前
不同 AI 生成 2026 年工作计划 PPT 的使用门槛对比
人工智能·python·powerpoint
小真zzz1 天前
ChatPPT免费功能之【导出PDF】:PPT内容安全+便捷分享
人工智能·ai·pdf·powerpoint·ppt·aippt
轻竹办公PPT1 天前
实测多款 AI:2026 年工作计划 PPT 哪种更好修改
人工智能·python·powerpoint
Xminyang2 天前
[图文并茂] PPT幻灯片:显示页码-增加总页码-更改任意位置
powerpoint·ppt添加页码
小真zzz2 天前
【2026新体验】ChatPPT的AI智能路演评测:PPT总结和问答都变的易如反掌
大数据·人工智能·ai·powerpoint·ppt·chatppt
成旭先生3 天前
文档(如word、ppt、pdf等)在线预览解决方案:基于HTML转换的技术实践与对比
pdf·word·powerpoint
dagouaofei3 天前
工作计划 PPT 使用 AI 生成,与传统制作方式有什么不同
人工智能·python·powerpoint
启途AI4 天前
2026免费好用的AIPPT工具榜:智能演示文稿制作新纪元
人工智能·powerpoint·ppt