【发布时间】:2019-07-26 14:03:33
【问题描述】:
我可以使用以下代码删除/覆盖一些元数据(存储在 core.xml 中):
def remove_metadata(prs):
"""Overwrites the metadata in core.xml however does not overwrite metadata which is stored in app.xml"""
prs.core_properties.title = 'PowerPoint Presentation'
prs.core_properties.last_modified_by = 'python-pptx'
prs.core_properties.revision = 1
prs.core_properties.modified = datetime.utcnow()
prs.core_properties.subject = ''
prs.core_properties.author = 'python-pptx'
prs.core_properties.keywords = ''
prs.core_properties.comments = ''
prs.core_properties.created = datetime.utcnow()
prs.core_properties.category = ''
prs = pptx.Presentation('my_pres.xml')
remove_metadata(prs)
这很有用 - 但还有其他元数据存储在 app.xml 中,例如 Company 和 Manager。我还需要清除这些属性。使用 python-pptx 如何编辑 app.xml 文件?
【问题讨论】:
标签: python-pptx