Skip to content

Releases: MHoroszowski/python-pptx

v1.2.0 — OOXML customXml support

05 May 17:06
0097f57

Choose a tag to compare

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). Explicit set_string / set_int / set_float / set_bool / set_datetime setters when Python type inference does the wrong thing.
  • Presentation.custom_xml_parts — Sequence wrapper. add(...) defaults to presentation scope (what Office.js writes). Pass scope="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

Quality

  • 190 dedicated tests across unit + integration; 96% line coverage on the new modules.
  • Full repo-wide ruff format pass 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.0

The 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 schemaRefs URIs.
  • Real third-party fixtures from SharePoint / Office.js / VSTO captured during a manual PowerPoint UI matrix.