A surgical XML injector for targeted PPTX template rendering and PresentationML mutation.
Project description
ppinject
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:
- Prepare deterministic text values in your application code.
- Render charts or other image assets separately.
- Call
render_template_slidewith placeholder values and image replacements. - 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_slideplusRenderReport - 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.mdfor API details and a variance-report-style example. - See
docs/USAGE.mdfor API details and the bundled example template workflow. - See
docs/ARCHITECTURE.mdfor XML mutation boundaries and tradeoffs. - See
docs/ROADMAP.mdfor planned expansion beyond the initial template-rendering scenario. - See
examples/render_template_slide.pyfor 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
- Keep the supported behavior statement narrow and honest.
- Validate produced files in PowerPoint on Windows, not only via ZIP/XML inspection.
- Use synthetic templates and assets in tests and examples.
- Run lint, type check, tests, build, and
twine checkbefore every release. - 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fec192263d7fa897fdcd3c813b0e0142453b569c41b50d062d3e0d602e6f9e26
|
|
| MD5 |
f1637e5550496addd4f16066ad888c6d
|
|
| BLAKE2b-256 |
ee7f31a97ebd71f276b2783e7244a8fcffd53936ef4f6726c61584d2379ee292
|
Provenance
The following attestation bundles were made for ppinject-0.1.0b2.tar.gz:
Publisher:
publish-pypi.yml on KyleDerZweite/ppinject
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ppinject-0.1.0b2.tar.gz -
Subject digest:
fec192263d7fa897fdcd3c813b0e0142453b569c41b50d062d3e0d602e6f9e26 - Sigstore transparency entry: 1308304295
- Sigstore integration time:
-
Permalink:
KyleDerZweite/ppinject@7dbb1817edb58179afa2aad29128a51f15180213 -
Branch / Tag:
refs/tags/v0.1.0b2 - Owner: https://github.com/KyleDerZweite
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@7dbb1817edb58179afa2aad29128a51f15180213 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f24e29c78cd45a7faa75e38e1f36d3475ae2e746c63e7fc0defa9693affa27c3
|
|
| MD5 |
e389f4721a52564a5402a265b678c802
|
|
| BLAKE2b-256 |
85e95f2c7921fd49b81e8955c35816bcf57cee9148679e570992964c74cf246c
|
Provenance
The following attestation bundles were made for ppinject-0.1.0b2-py3-none-any.whl:
Publisher:
publish-pypi.yml on KyleDerZweite/ppinject
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ppinject-0.1.0b2-py3-none-any.whl -
Subject digest:
f24e29c78cd45a7faa75e38e1f36d3475ae2e746c63e7fc0defa9693affa27c3 - Sigstore transparency entry: 1308304410
- Sigstore integration time:
-
Permalink:
KyleDerZweite/ppinject@7dbb1817edb58179afa2aad29128a51f15180213 -
Branch / Tag:
refs/tags/v0.1.0b2 - Owner: https://github.com/KyleDerZweite
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@7dbb1817edb58179afa2aad29128a51f15180213 -
Trigger Event:
release
-
Statement type: