Releases: MHoroszowski/python-pptx
Releases · MHoroszowski/python-pptx
v1.2.0 — OOXML customXml support
python-pptx-extended 1.2.0 — OOXML customXml support
Adds first-class support for the two OOXML mechanisms applications use to embed structured data in .pptx files:
- Custom Document Properties at
/docProps/custom.xml— name/value pairs visible in PowerPoint's File → Properties → Advanced. - CustomXml data parts at
/customXml/itemN.xml— arbitrary XML payloads with caller-defined namespaces, the mechanism Office.js, SharePoint, and VSTO add-ins use.
What's new
from pptx import Presentation
prs = Presentation("input.pptx")
# Custom doc properties — typed dict
prs.custom_properties["Source"] = "deck-builder-cli@1.4.2"
prs.custom_properties["BuildNumber"] = 42
prs.custom_properties["IsDraft"] = True
# customXml data parts — arbitrary XML, supports both Office.js and VSTO topologies
prs.custom_xml_parts.add(
b'<provenance xmlns="urn:my:p"><source>cli</source></provenance>',
name="provenance",
schema_refs=["urn:my:p"],
)
prs.custom_xml_parts.add(b"<x/>", scope="package") # VSTO/SharePoint topology
# String-blob helper for round-tripping a string verbatim (e.g. markdown)
prs.custom_xml_parts.add_string_blob(
"readme",
"# Hello\n\nMarkdown content embedded in the .pptx",
mime_hint="text/markdown",
)
prs.save("output.pptx")Three lookup forms: custom_xml_parts[i], custom_xml_parts["item3.xml"], custom_xml_parts.by_guid("{...}"), custom_xml_parts.by_name("provenance").
Highlights
Presentation.custom_properties— Mapping wrapper with type-dispatched assignment (str/int/float/bool/datetime → vt:lpwstr/i4/r8/bool/filetime). Explicitset_string/set_int/set_float/set_bool/set_datetimesetters when Python type inference does the wrong thing.Presentation.custom_xml_parts— Sequence wrapper.add(...)defaults to presentation scope (what Office.js writes). Passscope="package"for the VSTO / SharePoint topology.add_string_blob(...)/read_string_blob(...)— convenience for the common "embed a string and read it back" use case.- Round-trip safety — files containing customXml parts authored by SharePoint, Office.js, or VSTO load and save without losing their content.
Documentation
- User guide:
docs/user/custom-xml.rst - OOXML analysis (relationship topology, design rationale):
docs/dev/analysis/customxml.rst - Implementation plan:
Plans/customxml-implementation-plan.md
Quality
- 190 dedicated tests across unit + integration; 96% line coverage on the new modules.
- Full repo-wide
ruff formatpass landed alongside this release. - Verified on Python 3.9, 3.10, 3.11, 3.12 in CI.
Install
pip install python-pptx-extended==1.2.0The import name remains pptx — existing user code continues to work unchanged.
Out of scope (future work)
- Per-slide / per-shape
<p:custDataLst><p:tags>— separate follow-up PR. - Office.js-style schema validation against
schemaRefsURIs. - Real third-party fixtures from SharePoint / Office.js / VSTO captured during a manual PowerPoint UI matrix.