pptx
A pure-Rust library for reading and writing PowerPoint (.pptx) files. Open existing presentations, inspect every element, modify them, and save — or build new ones from scratch. Only 4 dependencies, no unsafe code.
Why pptx?
- Read and write — Not just generation. Open an existing
.pptx, parse its shapes, text, tables, and charts, modify them, and round-trip back to a valid file. Most Rust PPTX crates are write-only. - Feature-rich — Animations, 3D effects, SmartArt parsing, freeform shapes, group shapes — things other Rust PPTX crates don't cover.
- Lightweight — 4 runtime dependencies (
zip,quick-xml,thiserror,sha1). No regex, no HTTP client, no syntax highlighter bundled in. - Safe —
#![forbid(unsafe_code)]at the crate root. All key types areSend + Sync.
The API design draws from python-pptx, so concepts and naming will feel familiar if you've used it. See COMPATIBILITY.md for the detailed feature matrix.
Features
Slides & Layout
- Create, delete, reorder slides
- 11 built-in slide layouts with placeholder inheritance
- Slide backgrounds (solid, gradient, image)
- Speaker notes, sections, comments
Shapes & Text
- 180+ preset geometries (AutoShape)
- Freeform shapes with custom paths (
line_to,curve_to,close) - Group shapes with nesting
- Rich text: bold, italic, color, size, alignment, bullets, strikethrough, sub/superscript
- Right-to-left text direction (
TextDirectionenum) - Hyperlinks and action settings on shapes and text
Tables & Charts
- Tables with cell merging, borders, and per-cell formatting
- 20+ chart types (bar, line, pie, scatter, bubble, area, radar, stock, surface, 3D variants)
- Combo charts with dual axes (bar + line via
ComboChartData) - Chart axes, legends, data labels, markers
- Embedded Excel data for charts
Media
- Images with SHA1 deduplication and SVG support
- Image cropping (LTRB crop via
set_crop,set_crop_left, etc.) - Video and audio embedding
Effects & Animations
- Shadow effects (outer, inner, perspective)
- 3D effects: Bevel, Camera, LightRig, Scene3D, Shape3D
- Slide transitions (11 types)
- Animations: entrance, exit, emphasis effects with trigger and sequence control
Export
- PPTX to self-contained HTML (
export_html())
Advanced
- SmartArt reading and node-tree parsing
- Theme color scheme reading and modification
- Core properties (Dublin Core metadata)
- Print/handout settings (
PrintSettings: color mode, page orientation, handout layout) - PPTX validation and repair (
PptxValidator,PptxRepairer) - Digital signature metadata (structural XML; cryptographic signing not included)
- OLE object support
- Custom XML parts
- VBA macro support (
.pptmsave) - Embedded fonts
Installation
[]
= "0.1"
CLI Tool
A command-line interface for working with PPTX files is available:
Subcommands:
pptx-cli info— Show presentation metadata and slide countpptx-cli slides— List slides with titles and layoutspptx-cli export-html— Export a presentation to self-contained HTMLpptx-cli validate— Check a PPTX file for structural issuespptx-cli repair— Attempt to fix common PPTX problems
Quick Start
Create a new presentation
use Presentation;
Open and inspect an existing file
use ;
Add a chart
use Presentation;
use CategoryChartData;
use XlChartType;
use ;
Minimum Supported Rust Version (MSRV)
Rust 1.85 or later.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
License
Licensed under the MIT License.