ppt-rs
The Rust library for generating PowerPoint presentations that actually works.
While other Rust crates for PPTX generation are incomplete, broken, or abandoned, ppt-rs generates valid, production-ready PowerPoint files that open correctly in PowerPoint, LibreOffice, Google Slides, and other Office applications.
Related: For Excel, see xls-rs.
MCP: Build with --features mcp and run ppt_mcp — a Model Context Protocol server (rmcp) so Cursor, Claude Desktop, and other MCP clients can create, read, export, and validate .pptx via stdio. See MCP server.
NEW v0.2.19: PowerPoint zero-repair compatibility gate — multiple slide layouts, template-based generation, chart Excel workbook embedding, handout master packaging, slide master completeness, and a structured core::package_validation API.
Why ppt-rs?
- 🤖 MCP server - Optional
ppt_mcpbinary exposes presentation workflows as MCP tools for AI assistants and IDE integrations (--features mcp). - 🚀 Markdown to PPTX - Write slides in Markdown, get PowerPoint files. Perfect for developers.
- 🌐 HTML to PPTX - Convert HTML pages/snippets to PowerPoint with the
html2pptcommand orHtml2PptAPI - 🎨 Embedded themes - Brand decks with custom colors and fonts via
PresentationTheme(v0.2.16) - ⚡ Large decks - Lazy slide loading and optimized generation for 100+ slides (v0.2.17)
- 🧩 Templates & layouts - Clone masters/theme/layouts from an existing deck (
--template) and pick from 7 slide layouts per slide (v0.2.19) - 🛡️ PowerPoint compat gate - Structured
validate_package_bytes()report + debug assert on every generated deck so files open without repair (v0.2.19) - 📊 Editable charts - Charts embed an Excel workbook (
ppt/embeddings/*.xlsx) so they're editable in PowerPoint (v0.2.19) - 🔄 Round-trip capable - Export to Markdown, HTML, images (PNG/JPEG), compress PPTX files
- ✅ Actually works - Generates valid PPTX files that open in all major presentation software
- ✅ Complete implementation - Full ECMA-376 Office Open XML compliance
- ✅ Type-safe API - Rust's type system ensures correctness
- ✅ Simple & intuitive - Builder pattern with fluent API
Quick Start
Markdown to PowerPoint (Recommended)
The easiest way to create presentations: write Markdown, get PowerPoint.
1. Create a Markdown file:
- -
- --
- -
2. Convert to PPTX:
# Auto-generates slides.pptx
# Or specify output
# With custom title
That's it! You now have a valid PowerPoint file that opens in PowerPoint, Google Slides, LibreOffice, and more.
Create from a Template (v0.2.19)
Clone masters, layouts, theme, and table styles from an existing .pptx so new slides inherit the source deck's branding:
# CLI: use a template deck
use ;
use SlideLayout;
let slides = vec!;
// Masters/theme/layouts are copied from brand.pptx into output.pptx
let pptx = create_pptx_with_template?;
write?;
// Or via PresentationSettings:
use ;
let settings = new.template;
let pptx = create_pptx_with_settings?;
SlideLayout variants (each maps to slideLayoutN.xml on slide master 1): CenteredTitle (1), TitleAndContent (2), TwoColumn (3), SectionHeader (4), Blank (5), TitleOnly (6), TitleAndBigContent (7). When a template has fewer layouts, the index falls back to layout 1.
HTML to PowerPoint
Convert HTML directly to PowerPoint presentations — perfect for web content, documentation, and reports. Supports extended CSS, real image downloading, hyperlink handling, and styled tables with header rows.
1. CLI — Convert an HTML file:
# Auto-generates slides.pptx from slides.html
# Specify output file
# With custom title
2. Programmatic API — Parse HTML strings or files:
use create_pptx_with_content;
use parse_html;
let html = r#"
<h1>Introduction</h1>
<p>Welcome to the presentation</p>
<ul>
<li>Point one</li>
<li>Point two</li>
</ul>
<h1>Data</h1>
<table>
<tr><th>Item</th><th>Value</th></tr>
<tr><td>A</td><td>100</td></tr>
</table>
"#;
let slides = parse_html?;
let pptx = create_pptx_with_content?;
write?;
3. Html2Ppt struct with options:
use ;
let options = new
.max_slides
.max_bullets
.include_code;
let slides = with_options.parse_file?;
HTML element mapping:
| HTML | PPTX Result |
|---|---|
<h1> |
New slide with title |
<h2>–<h6> |
Bold section headers |
<p> |
Bullet points |
<ul>/<ol> |
List items |
<table> |
Table with styled header |
<pre>/<code> |
Code blocks |
<blockquote> |
Speaker notes |
<hr> |
Slide break |
<img> |
Image embedding (real URLs & local files) |
<a href> |
Hyperlink preservation |
style="" |
Enhanced CSS (margins, padding, borders, etc.) |
Library (Simplified API)
use *;
Simplified API Features:
- 🎨 Color Aliases:
red(),blue(),green(),orange(),material_blue(), etc. - 🌈 Color Adjustments:
.lighter(),.darker(),.opacity(),.mix() - 📊 Quick Tables:
QuickTable::new(cols).header().row().build() - 🔷 Shape Helpers:
rect(),circle(),ellipse(),triangle(),diamond() - ✨ Extension Methods:
.fill(),.stroke(),.text()(shorter than.with_fill(), etc.)
Library (Full API)
use Presentation;
use SlideContent;
Features
Core Capabilities
- Slides - Multiple layouts (title-only, two-column, blank, etc.)
- Text - Titles, bullets, formatting (bold, italic, colors, sizes)
- Bullet Styles - Numbered, lettered, Roman numerals, custom characters, hierarchical
- Text Enhancements - Strikethrough, highlight, subscript, superscript
- Tables - Cell formatting (alignment, wrap, merge), shared header presets for HTML/Markdown import
- Shapes - 100+ shape types with gradient fills and transparency
- Connectors - Straight, elbow, curved with arrows and dash styles
- Charts - Bar, line, pie charts with multiple series
- Images - Embed from files, bytes, base64, URL, auto-detect format, 8 visual effects
- Themes - Embedded
theme1.xmlwith 7 presets and custom color/font schemes (v0.2.16) - Media - Video (mp4, webm) and audio (mp3, wav) embedding
- Layouts - 7 slide layouts (Title, Title+Content, Two Column, Section Header, Blank, Title Only, Big Content) with per-slide
with_layout()(v0.2.19) - Templates -
--template deck.pptxCLI flag +PptxTemplate/create_pptx_with_templateAPI to clone masters/theme/layouts from an existing file (v0.2.19) - Charts (editable) - Charts embed an Excel workbook so they're editable in PowerPoint, not cache-only XML (v0.2.19)
- Validation -
core::package_validationexposesvalidate_package_bytes()returning a structuredPackageValidationReport(v0.2.19) - Reading - Parse and modify existing PPTX files
- Enhanced HTML Import - Real image downloading, extended CSS, hyperlink handling
- Enhanced Markdown Import - Real image URLs, task lists, strikethrough formatting
- Enhanced HTML Export - Interactive navigation, speaker notes, keyboard controls
- Performance - Borrow-based build API, lazy slide loading, pre-sized ZIP buffers (v0.2.17)
- Repair - Validate and fix damaged PPTX files
- MCP - Optional ppt_mcp stdio server (Model Context Protocol; Cargo feature
mcp) exposes creation, Markdown conversion, export, merge, validation, tables, and charts to MCP clients
Markdown Format
The Markdown format supports rich content:
| Syntax | Result |
|---|---|
# Heading |
New slide with title |
## Subheading |
Bold bullet point |
- Bullet |
Bullet points (also *, +) |
- [x] Task |
Task list with completed checkbox |
- [ ] Todo |
Task list with uncompleted checkbox |
1. Item |
Numbered list |
**bold** |
Bold text |
*italic* |
Italic text |
~~strikethrough~~ |
Strikethrough text |
`code` |
Inline code |
> Quote |
Speaker notes |
| ` | Table |
```code``` |
Syntax-highlighted code blocks |
```mermaid |
Mermaid diagrams (12 types) |
| ` | |
| ` | Real image embedding (local & web URLs) |
--- |
Slide break |
Code Block Syntax Highlighting: Code blocks are rendered with Solarized Dark theme colors:
- Blue - Keywords (
fn,let,def,class) - Yellow - Function names
- Cyan - Strings
- Green - Operators, macros
- Violet - Numbers
- Orange - Format specifiers
Example:
- -
```python
print("Hello!")
Conclusion
- Summary
- Q&A
Convert with: `pptcli md2ppt presentation.md` → `presentation.pptx`
## CLI Commands
### Convert HTML to PowerPoint
Convert HTML files or snippets to PowerPoint presentations:
```bash
pptcli html2ppt input.html [output.pptx] [--title "Title"] [--max-slides N] [--max-bullets N]
Options: --no-images, --no-tables, --no-code to disable specific content types.
Validate PPTX Files
Validate a PPTX file for ECMA-376 compliance:
This checks:
- ZIP archive integrity
- Required XML files presence
- XML validity
- Relationships structure
Structured package validation (v0.2.19) — run the same engine the generator self-checks with:
use ;
let bytes = read?;
let report = validate_package_bytes;
println!;
for issue in &report.issues
assert!; // true when there are no Error-severity findings
PackageValidationReport categorizes findings (ValidationCategory: MissingPart, Relationship, ContentType, Presentation, SlideMaster, Slide, Chart, Xml, Theme) and splits them by ValidationSeverity (Warning / Error). The legacy validate_powerpoint_structure() / CompatReport wrapper is kept for backward compatibility.
Show Presentation Information
Repair PPTX Files
Repair damaged or corrupted PPTX files:
use PptxRepair;
// Open and validate
let mut repair = open?;
let issues = repair.validate;
println!;
for issue in &issues
// Repair and save
let result = repair.repair;
if result.is_valid
Detectable Issues:
- Missing required parts (Content_Types.xml, relationships)
- Invalid or malformed XML
- Broken relationship references
- Missing slide references
- Orphan slides
- Invalid content types
Export & Compression
Export to Markdown:
use Presentation;
use MarkdownOptions;
let pres = with_title
.add_slide;
// Simple export
pres.save_as_markdown?;
// With options
let options = new
.with_slide_numbers
.with_gfm_tables;
pres.save_as_markdown_with_options?;
Export to Images:
use ;
// Export all slides as PNG
let options = new
.with_format
.with_dpi;
let paths = pres.save_as_images?;
// Generate thumbnail
pres.save_thumbnail?;
Compress PPTX:
use CompressionOptions;
// Analyze file size
let analysis = pres.analyze_size?;
println!;
// Compress with web optimization preset
let options = web;
let result = pres.compress?;
println!;
MCP server (Model Context Protocol)
Use ppt_mcp to drive ppt-rs from MCP-compatible clients over stdio (newline-delimited JSON-RPC). The implementation tracks the MCP handshake (initialize with protocolVersion, clientInfo, then notifications/initialized).
Build & run
Integration tests (serial stdio harness):
Client configuration
Point your MCP client at the ppt_mcp binary (use an absolute path if the client does not inherit your PATH), for example:
Works with editors and assistants that support MCP (e.g. Cursor, Claude Desktop, others).
Exposed tools
| Tool | Purpose |
|---|---|
create_presentation |
Build a deck from structured slide titles/bullets |
markdown_to_pptx |
Convert Markdown to .pptx |
get_pptx_info |
Metadata: title, slide count, summaries |
export_pptx |
Export to html, pdf, markdown, or png |
merge_pptx |
Merge multiple presentations |
validate_pptx |
Structural / ECMA-376 validation |
create_presentation_with_tables |
Deck with table slides |
create_presentation_with_charts |
Deck with bar/line/pie/area charts |
Enable the library integration with features = ["mcp"] when depending on ppt-rs from another crate.
Installation
Add to Cargo.toml:
[]
= "0.2.19"
# Optional: MCP server types / embedding (library module `ppt_rs::mcp`)
# ppt-rs = { version = "0.2.19", features = ["mcp"] }
Examples
Full walkthrough of the simplified helpers, charts, themes, export, and validation: API_GUIDE.md.
Tables
use ;
use ;
// Shared header preset (used by HTML/Markdown import)
let table = table_from_string_rows;
// Manual styling with alignment and merge
let styled_table = new
.add_row
.add_row
.position
.build;
let slides = vec!;
let pptx = create_pptx_with_content?;
Charts
use ;
// Create a bar chart
let chart = new
.categories
.add_series
.add_series
.position
.size
.build;
// Add to slide
let slide = new.add_chart;
Slide Transitions
use ;
// Create slide with transition
let slide = new
.with_transition; // Push, Fade, Cut, Cover, etc.
Table Merging
use ;
let table = new
.add_row
.add_row
.add_row
.build;
Shapes
use ;
use ;
// Simple shape with solid fill
let shape = new
.with_fill
.with_text;
// Shape with gradient fill
let gradient_shape = new
.with_gradient
.with_text;
// Shape with transparency
let transparent = new
.with_fill
.with_line;
Connectors
use ;
// Straight connector with arrow
let conn = straight
.with_line
.with_end_arrow
.with_arrow_size;
// Elbow connector with dashed line
let elbow = elbow
.with_line
.with_arrows;
Bullet Styles
use ;
// Numbered list
let slide = new
.add_numbered
.add_numbered
.add_numbered;
// Lettered list (a, b, c)
let slide = new
.add_lettered
.add_lettered;
// Roman numerals (I, II, III)
let slide = new
.add_styled_bullet
.add_styled_bullet
.add_styled_bullet;
// Custom bullet characters
let slide = new
.add_styled_bullet
.add_styled_bullet
.add_styled_bullet;
// Hierarchical (sub-bullets)
let slide = new
.add_bullet
.add_sub_bullet
.add_sub_bullet;
Text Enhancements
use BulletPoint;
use font_sizes;
// Per-bullet formatting
let strikethrough = new.strikethrough;
let highlighted = new.highlight;
let subscript = new.subscript;
let superscript = new.superscript;
let styled = new.bold.color;
// Per-bullet font sizes
let large_text = new.font_size;
let small_text = new.font_size;
// Add to slide
let mut slide = new;
slide.bullets.push;
slide.bullets.push;
slide.bullets.push;
Font Size Presets
use font_sizes;
// Available presets (in points)
TITLE // 44pt
SUBTITLE // 32pt
LARGE // 36pt
HEADING // 28pt
BODY // 18pt
SMALL // 14pt
CAPTION // 12pt
// Use with slide content
let slide = new
.title_size
.content_size;
Images from Base64
use ;
use inches;
// From base64 encoded string
let base64_png = "iVBORw0KGgoAAAANSUhEUg...";
let img = from_base64
.position;
// From raw bytes
let bytes = vec!; // PNG data
let img = from_bytes;
// Using builder
let img = from_base64
.position
.build;
Image Effects
Apply professional visual effects to images with a simple, chainable API:
use ImageBuilder;
use inches;
// Simple: Load from file with auto-detection
let img = from_file
.at
.build;
// Auto-detect format from bytes
let bytes = read?;
let img = auto
.at
.build;
// Chainable effects - shadow
let img = from_file
.at
.shadow
.build;
// Chainable effects - reflection
let img = from_file
.at
.reflection
.build;
// Chainable effects - glow
let img = from_file
.at
.glow
.build;
// Multiple effects combined
let img = from_file
.at
.shadow
.reflection
.build;
// With cropping (10% from each side)
let img = from_file
.at
.crop
.build;
// All together: size, position, effects, crop
let img = from_file
.size
.at
.shadow
.glow
.crop
.build;
Supported Effects:
- Shadow - Outer drop shadow with blur and offset
- Reflection - Mirror effect below the image
- Glow - Golden aura around the image
- Soft Edges - Feathered/vignette borders
- Inner Shadow - Inset shadow for depth
- Blur - Artistic defocus effect
- Crop - Trim edges (percentage-based)
- Combined - Multiple effects together
Supported Formats:
- JPEG/JPG - Full support with all effects
- PNG - Full support with all effects
- GIF - Basic support
- Dynamic loading from
examples/assets/folder
What Makes This Different
Unlike other Rust PPTX crates that:
- ❌ Generate invalid files that won't open
- ❌ Have incomplete implementations
- ❌ Are abandoned or unmaintained
- ❌ Lack proper XML structure
ppt-rs:
- ✅ Generates valid PPTX files from day one
- ✅ Actively maintained with comprehensive test coverage (1100+ tests)
- ✅ Complete XML structure following ECMA-376 standard
- ✅ Validation tools - Built-in validation command + structured
PackageValidationReportAPI for quality assurance - ✅ PowerPoint compat gate - Every generated deck is self-validated in debug builds
- ✅ Alignment testing - Framework for ensuring compatibility with python-pptx
- ✅ Production-ready - used in real projects
Quality Assurance
Validation
- Built-in validation command for ECMA-376 compliance checking
- Structured
core::package_validationAPI (validate_package_bytes→PackageValidationReport) - Debug builds
debug_assert!that every generated deck passes package validation - Comprehensive test suite (1100+ tests, including
package_validation_test,powerpoint_compat_test,layouts_packaging_test,repair_compare_test) - Integration tests for end-to-end validation
Alignment Testing
- Framework for comparing output with python-pptx standards
- Alignment testing scripts and documentation
- See
examples/alignment_test.rsfor details
Technical Details
- Version: 0.2.19
- Format: Microsoft PowerPoint 2007+ (.pptx)
- Standard: ECMA-376 Office Open XML
- Compatibility: PowerPoint, LibreOffice, Google Slides, Keynote
- Architecture: Modular design with clear separation of concerns
- Test Coverage: 1100+ tests covering all major features
- Performance: ~1000 slides/sec; lazy loading for large decks; borrow-based
build()API
Templates
Create presentations quickly with pre-built templates:
use ;
// Business proposal template
let proposal = business_proposal?;
// Status report template
let status = status_report?;
// Quick simple presentation
let simple = simple?;
Available templates: business_proposal, training_material, status_report, technical_doc, simple
Themes
Pre-defined color palettes for shape styling, plus embedded PPTX themes that PowerPoint applies to new content:
use themes;
use ;
use ;
let slide = new.add_bullet;
// Embed a theme in the generated PPTX (theme1.xml)
let pptx = with_title
.add_slide
.with_theme
.into_bytes?; // consuming build — no slide clone
// Or from a prelude preset
let pptx = with_title
.add_slide
.with_theme
.build?;
// Custom colors and fonts via settings
let slides = vec!;
let theme = modern
.major_font
.minor_font;
let settings = new.theme;
let pptx = create_pptx_with_settings?;
Prelude presets for shape colors: themes::CORPORATE, MODERN, VIBRANT, DARK, NATURE, TECH, CARBON. Convert any preset to an embedded theme with .to_presentation_theme().
Built-in PresentationTheme presets: office(), corporate(), modern(), vibrant(), dark(), nature(), tech(), carbon(). Build fully custom schemes with ThemeColorScheme::from_palette() or PresentationTheme::new("Brand").colors(...).
Large Presentations
For decks with 100+ slides, use lazy slide loading to generate on demand:
use ;
use File;
let file = create?;
create_pptx_lazy_to_writer?;
Profile generation with ppt_rs::generator::memory_profile::{profile_eager_generation, profile_lazy_generation, sample_slides}.
Extended Color Palettes
use colors;
// Basic colors
RED, GREEN, BLUE, WHITE, BLACK
// Corporate colors
CORPORATE_BLUE, CORPORATE_GREEN, CORPORATE_RED
// Material Design colors
MATERIAL_RED, MATERIAL_BLUE, MATERIAL_GREEN
MATERIAL_PURPLE, MATERIAL_INDIGO, MATERIAL_CYAN
MATERIAL_TEAL, MATERIAL_LIME, MATERIAL_AMBER
// IBM Carbon Design colors
CARBON_BLUE_60, CARBON_BLUE_40
CARBON_GRAY_100, CARBON_GRAY_80, CARBON_GRAY_20
CARBON_GREEN_50, CARBON_RED_60, CARBON_PURPLE_60
Layout Helpers
Position shapes easily with layout helpers:
use layouts;
// Center a shape on the slide
let = center;
// Create a grid of positions
let positions = grid; // 2x3 grid
// Stack shapes horizontally
let positions = stack_horizontal;
// Evenly distribute shapes
let positions = distribute_horizontal;
Advanced Features
- Prelude Module: Simplified API with macros (
pptx!,shape!), unit helpers (inches(),cm()), and color constants - Templates: Pre-built presentation structures (business proposal, status report, training material, technical doc)
- Gradient Fills: Linear gradients with multiple stops and directions (horizontal, vertical, diagonal, custom angle)
- Transparency: Alpha transparency for solid fills (0-100%)
- Connectors: Straight, elbow, curved with arrow types (triangle, stealth, diamond, oval, open) and dash styles
- Tables: Cell formatting, colors, alignment, borders
- Charts: Bar, line, pie, area, scatter, doughnut, radar, and more; editable in PowerPoint via embedded Excel workbook (v0.2.19)
- Shapes: 100+ shape types with fills, outlines, and text
- Animations: 50+ animation effects (fade, fly, zoom, etc.)
- Transitions: 27 slide transition effects
- SmartArt: 25 SmartArt layouts (lists, processes, cycles)
- Media: Video and audio embedding (mp4, webm, mp3, wav)
- 3D Models: GLB, GLTF, OBJ, FBX, STL formats
- VBA Macros: Support for .pptm files with macros
- Custom XML: Embed custom data in presentations
- Themes: Embedded color schemes and font definitions in
theme1.xml - Performance: Lazy slide loading, borrow-based build, optimized package XML
- Speaker Notes: Add notes to slides
See ARCHITECTURE.md for detailed documentation.
License
Apache-2.0
Contributing
Contributions welcome! See TODO.md for current priorities.