Skip to main content

A surgical XML injector for targeted PPTX template rendering and PresentationML mutation.

Project description

ppinject

CI

A surgical XML injector for .pptx files.

ppinject is an API-first library for targeted PresentationML mutations inside the PPTX archive while preserving layout, relationships, and neighboring XML whenever feasible.

Status: Beta - narrow API-first MVP

Release note

0.1.0b2 is the first public PyPI beta release. It supports deterministic rendering of an existing PPTX template slide by replacing text placeholders and existing picture shapes.

The repository ships a synthetic example template at examples/Template_Slide.pptx.

Who this is for

ppinject is useful when you already have a PowerPoint template with approved layout and formatting, and your application only needs to fill known placeholders and swap existing image slots without rebuilding the presentation.

Typical workflow:

  1. Prepare deterministic text values in your application code.
  2. Render charts or other image assets separately.
  3. Call render_template_slide with placeholder values and image replacements.
  4. Open the output in PowerPoint with layout and neighboring XML preserved where feasible.

Current supported scenario

The current release supports one production scenario:

  • render one existing PPTX template slide to a new output file
  • replace text placeholders that resolve within a single paragraph, even if PowerPoint split them across multiple <a:t> nodes
  • replace existing picture shapes by shape name while keeping the original media part paths and extensions
  • return a structured render report with replaced and missing keys

Public entry point:

from ppinject import render_template_slide

Quick example

from ppinject import render_template_slide

report = render_template_slide(
	"examples/Template_Slide.pptx",
	"rendered_slide_part_a.pptx",
	text_replacements={
		"data1": "Demo Value 1",
		"data2": "Demo Value 2",
		"data3": "Demo Value 3",
		"data4": "Demo Value 4",
		"year-1": "2025",
		"year": "2026",
		"k-3": "Metric A",
		"k-2": "Metric B",
		"k-1": "Metric C",
		"b-v-3": "100",
		"b-v-2": "200",
		"b-v-1": "300",
		"c-v-3": "110",
		"c-v-2": "220",
		"c-v-1": "330",
		"v-p-3": "10",
		"v-p-2": "12",
		"v-p-1": "15",
		"headline": "Synthetic example output",
	},
	image_replacements={
		"Grafik 46": "example_chart.png",
		"Grafik 54": "example_chart.png",
	},
)

print(report)

Current constraints

  • the first supported scenario is deterministic rendering of an existing PPTX template slide
  • placeholder replacement currently assumes the placeholder text belongs to one paragraph, even if PowerPoint split it across multiple <a:t> nodes
  • image replacement currently targets existing picture shapes and keeps the original media part names and extensions
  • the current public API is intentionally small: render_template_slide plus RenderReport
  • broader slide authoring and general-purpose PresentationML mutation are still out of scope

It does not yet contain a broad general-purpose PPTX object model.

Documentation

  • See docs/USAGE.md for API details and a variance-report-style example.
  • See docs/USAGE.md for API details and the bundled example template workflow.
  • See docs/ARCHITECTURE.md for XML mutation boundaries and tradeoffs.
  • See docs/ROADMAP.md for planned expansion beyond the initial template-rendering scenario.
  • See examples/render_template_slide.py for a small example wired to the bundled template.

Development setup (uv)

Prerequisites

  • Python 3.11+
  • uv

Quick start

uv sync --dev
uv run pre-commit install

Quality checks

uv run pre-commit run --all-files
uv run ruff check .
uv run mypy .
uv run pytest -q
uv build
uv run twine check dist/*

Publish-readiness checklist

  1. Keep the supported behavior statement narrow and honest.
  2. Validate produced files in PowerPoint on Windows, not only via ZIP/XML inspection.
  3. Use synthetic templates and assets in tests and examples.
  4. Run lint, type check, tests, build, and twine check before every release.
  5. Add release notes for every published version that describe supported and unsupported cases clearly.

License

ppinject is open source under the GNU General Public License v3.0 or later (GPL-3.0-or-later). See LICENSE for the full license text.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ppinject-0.1.0b2.tar.gz (645.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ppinject-0.1.0b2-py3-none-any.whl (31.3 kB view details)

Uploaded Python 3

File details

Details for the file ppinject-0.1.0b2.tar.gz.

File metadata

  • Download URL: ppinject-0.1.0b2.tar.gz
  • Upload date:
  • Size: 645.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ppinject-0.1.0b2.tar.gz
Algorithm Hash digest
SHA256 fec192263d7fa897fdcd3c813b0e0142453b569c41b50d062d3e0d602e6f9e26
MD5 f1637e5550496addd4f16066ad888c6d
BLAKE2b-256 ee7f31a97ebd71f276b2783e7244a8fcffd53936ef4f6726c61584d2379ee292

See more details on using hashes here.

Provenance

The following attestation bundles were made for ppinject-0.1.0b2.tar.gz:

Publisher: publish-pypi.yml on KyleDerZweite/ppinject

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ppinject-0.1.0b2-py3-none-any.whl.

File metadata

  • Download URL: ppinject-0.1.0b2-py3-none-any.whl
  • Upload date:
  • Size: 31.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ppinject-0.1.0b2-py3-none-any.whl
Algorithm Hash digest
SHA256 f24e29c78cd45a7faa75e38e1f36d3475ae2e746c63e7fc0defa9693affa27c3
MD5 e389f4721a52564a5402a265b678c802
BLAKE2b-256 85e95f2c7921fd49b81e8955c35816bcf57cee9148679e570992964c74cf246c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ppinject-0.1.0b2-py3-none-any.whl:

Publisher: publish-pypi.yml on KyleDerZweite/ppinject

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page