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',
  ...
}
相关推荐
西门子918!2 天前
Office(PPT)常用记录1
经验分享·powerpoint
ms365copilot2 天前
Excel做完≠结束,Copilot一键生成汇报PPT
powerpoint·excel·copilot
m0_547486663 天前
《深度学习技术基础》全套PPT课件2026
人工智能·深度学习·powerpoint
G智爱AI6 天前
2026工作汇报PPT AI工具实测|主流省时办公工具横向对比
人工智能·powerpoint
Felicia-侧听6 天前
PPT导出图片不清晰?PPT转图片清晰的三种方法
powerpoint·ppt转图片·ppt导出图片不清晰
MindUp6 天前
自然语言处理驱动的PPT自动生成:4款工具的技术实现与实测对比
人工智能·自然语言处理·powerpoint
AcaDesign8 天前
国家/省部市级科技奖答辩PPT_科技进步奖_自然科学奖_技术发明奖|WordinPPT
大数据·人工智能·科技·powerpoint
●VON9 天前
芯稿 MarkDeck 使用指南:用 Markdown 写出可编辑的 PPT
华为·编辑器·powerpoint·harmonyos·鸿蒙
MindUp11 天前
AI生成PPT工具的技术选型:从文档解析到自动布局的工程实现分析
人工智能·powerpoint
SpaceAIGlobal11 天前
AI PPT生成工具哪些支持PDF文档导入?
人工智能·ai·pdf·powerpoint·办公