Series: go-pptx Technical Blog (10 posts in total)
Baseline: v2.4.4 (2026-12)
Repository: github.com/F31/go-pptx; public import path: github.com/F31/go-pptx/v2/pptx
License: Apache-2.0
- Development Purpose: Filling the Gap in the Go Ecosystem for "Programmatic PPTX Processing" Presentations are one of the most common content carriers in enterprise and education scenarios, but "modifying PPT programmatically" has long been the territory of Python, Java, and .NET:
python-pptx depends on the Python interpreter;
Apache POI depends on the JVM;
LibreOffice UNO requires installing the entire office suite on the target machine;
Aspose.Slides is powerful but requires a commercial license and runtime;
Open XML SDK is bound to .NET.
The common requirements for Go server-side, however, are the opposite: single-binary deployment, zero runtime, static linking, and direct integration into containers and CI. If a Go service only wants to replace a few paragraphs of text in a template, embed images and audio into pages, or batch-generate hundreds of client proposals, yet must first install Python or invoke external processes, the architecture becomes awkward.
go-pptx targets exactly this category of "programmatic PPTX processing" scenarios:
Batch generation of template reports: open an existing template, replace text, table rows, and chart data by data, then save.
Fine-grained editing of existing documents: modify only the target region without "reading out and rewriting" the entire document, avoiding damage to unknown extensions and layout details.
Automated narration / voiceover PPT: convert notes to speaker scripts, embed audio, generate slide timing, and finally deliver a playable file.
Read-only auditing and comparison: structured inspection, capability disclosure, and semantic diff reports between two versions.
Browser-side privacy auditing: use WASM to inspect files locally; files are not uploaded.
In one sentence: Operate PPTX like a structured document, without depending on Office, LibreOffice, FFmpeg, or any interpreter.
- Design Goals: Six Capability Mainlines The design of go-pptx is not "wrapping every OOXML field with a layer"; instead, it makes trade-offs around six capability mainlines:
Mainline Goal Key Constraint
General read/write Create, parse, save, pages, shapes, images, text, notes, tables, supported charts Public object model aligns with the DrawingML hierarchy
Controllable fidelity Unmodified Parts and unknown XML preserved as-is; explicit refusal when safe execution is impossible Write path performs only SpanPatch, no full re-serialization
Fine-grained formatting Distinguish local formatting, inherited formatting, and layout results; cross-Run editing, group transforms, table styles Inheritance chain is explainable; failures produce diagnostics rather than silent guessing
Automated narration Rich-text notes, audio embedding, playback configuration, slide timing Pure Go media probing, no FFmpeg invocation
Engineering reliability Lazy parsing, resource budgets, transactional commit, validation reports, real-corpus regression, native fuzz CGO_ENABLED=0, errors returned rather than panic
Optional extensions Read-only IR, CLI, media probing, rendering adapter contract Core dependencies remain simple; extensions do not pollute the facade
Several hard rules that run throughout:
Byte fidelity first: unmodified Parts use raw byte copying; modified Parts receive only minimal patches. Saving an empty change set must be byte-identical (B1).
Transactional editing: first plan with pure-read validation, then apply a single-transaction commit; failure leaves zero residue.
Diagnose rather than silently corrupt: unsupported edits return stable error codes or Diagnostic, never "guess a result that looks close enough".
Budgets for untrusted input: Part count, XML size, media size, and cumulative decompressed read volume are all constrained by Budget.
API grading: paragraphs marked // Stable: promise backward compatibility; other symbols evolve according to the management contract.
- Technical Architecture: Facade + Domain Logic + Format Layer + Transport Layer Starting from v2.0, the module root is a "meta-repository" and no longer contains package pptx files; the only official public import path is the pptx/ subpackage. The internal implementation is layered by responsibility:
text
┌─────────────────────────────────────────────────────────┐
│ Public Facade github.com/F31/go-pptx/v2/pptx │
│ Presentation · Slide · Shape · TextFrame · TableShape │
│ ChartShape · PictureShape · AudioShape · VideoShape │
│ (currently 221 types · 44 top-level functions · 17 error sentinels) │
└────────────────────────┬────────────────────────────────┘
│
┌────────────────────────┴────────────────────────────────┐
│ Orchestration Layer internal/engine │
│ Inspect / Validate / Capability / IR shared by CLI and WASM │
└────────────────────────┬────────────────────────────────┘
│
┌────────────────────────┴────────────────────────────────┐
│ Domain Logic internal/document/{model,style,geometry,text, │
│ media,table} · chart · bind · ir · editplan │
└────────────────────────┬────────────────────────────────┘
│
┌────────────────────────┴────────────────────────────────┐
│ Format Layer internal/ooxml (read-only projection) │
│ internal/ooxml/schema (ECMA-376 generated types) │
└────────────────────────┬────────────────────────────────┘
│
┌────────────────────────┴────────────────────────────────┐
│ Transport Layer internal/opc (ZIP/relationships/content types/save plan/budget) │
│ internal/xmlstore (scan/index/SpanPatch) │
└─────────────────────────────────────────────────────────┘
Dependency direction is enforced in CI by internal/archlint: pptx → internal/* is allowed; internal/* → pptx is forbidden (internal/engine is the only explicit exception because it carries the facade-to-IR adaptation); new unregistered packages or cross-layer reverse references will directly fail go test.
Several key subsystems:
internal/xmlstore: namespace-aware scanner + node index + SpanPatch engine. It preserves the raw byte span of every element, so "change only one Run, keep all other bytes unchanged" is verifiable.
internal/opc: OPC package model, relationship graph, content types, SavePlan, atomic write-to-disk, resource budget.
internal/editplan: single-Part / multi-Part edit plans with unified transaction semantics.
internal/chart: chart XML construction, parsing, canonical validation, workbook synchronization.
internal/ir: read-only intermediate representation, timing IR, semantic diff.
internal/ooxml: read-only projection generated from the ECMA-376 Part 4 Transitional XSD, used by engine for auditing and IR projection.
- Competitive Analysis: Not "Yet Another python-pptx" The comparison below is based on public information and the project's self-testing criteria, focusing on "deployment form, editing fidelity, unknown extensions, and auditing capability" rather than simply comparing feature counts.
Dimension go-pptx python-pptx Apache POI (XSLF) LibreOffice UNO Aspose.Slides Open XML SDK
Language / runtime Go, zero runtime dependencies Python interpreter JVM C++/multi-language .NET/Java/cloud .NET
Deployment form Single binary / WASM Requires Python environment Requires JVM Requires LibreOffice installation Requires runtime + commercial license Requires .NET
Editing fidelity Byte-level precise patching, zero changes to untouched regions Reads out then rewrites the entire package Rebuilds document Rebuilds document Rebuilds document (relatively good fidelity) Full rewrite
Unknown extension preservation Preserved as raw bytes (Opaque policy) Depends on rewrite path, easily lost Depends on parse coverage Depends on parse coverage Depends on version Structural-level preservation
Browser-side offline read-only WASM, files never leave the device None None None Web API (requires upload) None
Capability self-describing manifest Yes (six-dimensional Supported/Partial/…) None None None None None
Semantic diff (page alignment) Built-in (weighted LCS + Jaccard) None None None Yes (difference comparison) None
Template data binding Built-in (inline/conditional/row loop/chart) Requires jinja2 etc. None Yes (macros/scripts) Yes (template API) None
Media duration/signature probing Pure Go (WAV/MP3/MP4/WebM) No built-in No built-in Yes Yes No built-in
License Apache-2.0 MIT Apache-2.0 MPL-2.0 Commercial MIT
It should be noted that:
Aspose.Slides remains stronger in feature coverage and rendering; go-pptx does not claim to "fully replace" it; its advantages are open source, zero runtime, byte fidelity, and self-hostability.
python-pptx has a great ecosystem and ease of use; go-pptx's differentiators are Go single-binary deployment and low-side-effect editing of existing documents.
"Fidelity" is not a slogan: the project constrains it with empty-change-set byte identity, real-sample single-Run replacement diff convergence to 1 byte, and client re-save verification.
Differentiation Points
The only pure Go implementation with "byte-level fidelity": modify only the target region, keep untouched regions as raw bytes; suitable for existing-document processing sensitive to "documents being damaged by tool rewrites".
Lack of a comparable PPTX SDK in the Go ecosystem: single binary, directly integrable into existing Go services/CI, WASM can run in the browser.
Built-in auditing and capability negotiation: Diff, Validate, and Capability let callers know before deployment which capabilities are available and which are limited.
Open source and self-hostable: Apache-2.0, no runtime/license costs, controllable costs for batch processing and automation scenarios.
- Feature Highlights: From "Can Change Text" to "Can Deliver" Current public capabilities can be roughly grouped by work package:
Category Capabilities
Creation New() built-in 4 standard layouts; AddSlide / AddSlideWithPlaceholders / NewBatch; text boxes, auto shapes, images, charts, tables, audio, video; WithSlideSize; move/delete pages and shapes
Text editing Paragraph / Run object model; cross-Run literal replacement (3 formatting strategies, grapheme cluster protection, br/field/link boundary safety); font/color/size patch and Reset; text box properties and slidenum/datetime fields
Visual writing SetFill / SetLine / SetBackground; shadow, glow, soft edge, reflection, inner shadow, fill overlay, blur; image cropping, SVG + PNG fallback; theme fonts/colors; batch add images/charts
Image/media PNG/JPEG etc. embedding with 4 Fit modes; media content hash deduplication; MP3/WAV/MP4/WebM pure Go probing; audio playback tree and timing plan
Charts/tables Column/line/pie/doughnut/area/radar/scatter/bubble/3D column; combo charts, secondary axes, series labels/styles/markers, axis gridlines/number formats; rich-text tables, merging, diagonal lines, style IDs and batch style parsing
Template binding Inline {{path}}, conditional paragraphs, table row loops, chart data binding; plan-phase pure-read validation + single-transaction atomic commit, zero residue on failure
Read-only auditing Read-only IR (schemaVersioned JSON), semantic Diff, Validate, six-dimensional Capability manifest
Fidelity mechanisms SpanPatch precise byte patching, unknown subtrees/extensions preserved as-is, revision concurrency protection, atomic write-to-disk and failure recovery
Browser-side WASM compilation target + offline static inspection page (files never leave the device, no external network/no CDN)
A set of current baseline numbers (v2.4.4):
Metric Value
Public API types 221
Stable paragraphs / symbols / methods 73 / 96 / 183
Exported methods / top-level functions 207 / 44
Error sentinels 17
Whole-repository coverage weighted approx. 84%+
Public corpus 36+ sample indexes (public golden samples + 33 private ext-* indexes)
L3 real devices PowerPoint 16 + WPS 12: 8/8 passed; v2.4.x additionally has a 13-page three-client comprehensive sample
- Quality and Validation: Turning "Works" into "Keeps Working" go-pptx does several things in engineering validation that are uncommon in similar projects:
Corpus regression: 30+ real sample indexes; public golden samples with a closed loop of "before modification / after modification / actions / smoke", reproducible in CI.
Byte-level assertions (B1): after saving an empty change set, the decompressed content of unmodified Parts is byte-identical; the diff interval of a single-Run replacement converges to 1 byte.
Client matrix (L3): PowerPoint 16 / WPS 12 real-device open, edit, re-save, and re-verify; v2.4.x expands to a 13-page comprehensive sample and LibreOffice.
Coverage gate: scripts/coverage/gate.sh sets thresholds per package; unregistered new packages fail directly.
Native fuzz: open path, text replacement, and template binding all have fuzz targets.
Performance baseline: three tiers of corpus × six benchmark categories (Open / Traverse / Replace / SaveMem / SaveDisk / PeakHeap).
Cross-builds: js/wasm, wasip1/wasm, darwin/arm64, linux/arm64, windows/amd64.
These contents will be expanded in post 9.
- Series Plan: What the Next 9 Posts Cover Post Topic Content Highlights 1 Overall overview Development purpose, design goals, technical architecture, competitive analysis, feature highlights, quality baseline (this post) 2 Byte-level fidelity xmlstore scanner, namespace environment, node index, SpanPatch contract, unknown subtree preservation, B1 evidence 3 OPC and transactions ZIP lazy indexing, relationships/content types, ChangeSet and SavePlan, single/multi-Part edit plans, revision, atomic save, raw passthrough 4 Object model and handles Cross-Run text replacement, rune/grapheme boundaries, three replacement strategies, cNvPr@id identity, STALE-GUARD, monotonic ID allocator 5 Chart subsystem Chart XML and embedded workbook, 9 chart types, combo charts/dual axes, series labels/styles/markers, canonical validation, client compatibility 6 Media and automated narration WAV/MP3/MP4/WebM pure Go probing, duration state semantics, media deduplication, playback tree, narrate/timing-plan, resource budget 7 Template data binding {{path}}/#if/#each/table row loops/chart binding, plan/apply two phases, zero residue, relationship with fidelity patching 8 Read-only auditing and semantic Diff IR projection, timing IR, weighted LCS + Jaccard page alignment, opaque diff, six-dimensional Capability, Validate diagnostics 9 Quality engineering 30+ corpora, public golden samples, B1 assertions, coverage gate, fuzz, three-client L3, performance guardrails, CI 10 Architecture evolution and cross-platform ADR-030 facade convergence, engine orchestration, archlint, ECMA-376 generation pipeline, CLI 9 subcommands, WASM offline, five-platform cross-builds Reading suggestions:
To quickly judge whether it suits your scenario: read posts 1, 3, and 9.
To understand "why it won't damage documents": read posts 2, 3, and 4.
To do reports/charts/voiceover: read posts 5, 6, and 7.
To do auditing/comparison/browser pre-checks: read posts 8 and 10.
- Boundaries and Trade-offs go-pptx is not a "universal PPTX engine", and currently explicitly does not promise:
No native rendering: the render subpackage only defines the adapter contract; the rendering.native capability status is Untested.
No full animation editing: the timing tree is mainly a read-only IR; it can detect conflicts but does not promise full playback evaluation.
No writing of encryption/signatures/OLE: recognized and explicitly refused rather than silently converted.
No promise to cover all OOXML features: chart types, styles, and effects all follow the pattern of "supported subset + capability disclosure + diagnostics".
No in-place saving of source files: source files are still lazily read; safe replacement and rollback semantics are not yet closed, and this is currently explicitly refused.
This "knowing what it does not do" boundary, together with the error model of "telling you explicitly why when it fails", is the biggest difference between go-pptx and tools that "look like they can change anything but actually silently lose content".
- Summary The core of go-pptx is not "rewriting python-pptx in Go", but solving three engineering problems together:
Fidelity: take raw bytes as the invariant and patch only the target region.
Transactions: validate before commit, zero residue on failure, concurrency guarded by revision.
Verifiability: real corpora, byte assertions, real-device clients, coverage, and fuzz jointly constrain "the capabilities it claims".
The next post starts from the lowest-level xmlstore and explains "why changing only one Run can leave all other bytes unchanged".

