ppt-rs-0.1.3 has been yanked.
ppt-rs
A Rust library for creating, reading, and updating PowerPoint (.pptx) files.
This is a Rust port of the python-pptx library, providing a safe and efficient way to work with PowerPoint files in Rust.
Features
- ✅ Create new PowerPoint presentations
- ✅ Read existing .pptx files
- ✅ Modify slides, shapes, text, images, and charts
- ✅ Full support for OpenXML format (ISO/IEC 29500)
- ✅ Comprehensive shape support (AutoShape, Picture, Connector, GraphicFrame, GroupShape)
- ✅ 100+ AutoShape types (rectangles, arrows, flowchart shapes, callouts, action buttons, etc.)
- ✅ Chart support with axes (CategoryAxis, ValueAxis, DateAxis)
- ✅ 100+ Chart types (Area, Bar, Column, Line, Pie, Scatter, Bubble, Radar, Stock, Surface, Cone, Cylinder, Pyramid, 3D variants)
- ✅ Table support with formatting options
- ✅ DrawingML support (colors, fills, lines)
- ✅ Hyperlink support for shapes and text
- ✅ Shape XML parsing and generation for reading/writing shapes
- ✅ 13+ Line dash styles (Solid, Dash, Dot, LongDash, SystemDash, etc.)
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Quick Start
use new_presentation;
// Create a new presentation
let mut prs = new_presentation?;
// Get slides collection
let mut slides = prs.slides;
// Add a slide
let layout_part = new?;
let slide = slides.add_slide?;
// Add a shape with hyperlink
use ;
let mut shape = new;
let hlink = with_address;
shape.set_hyperlink;
slide.add_shape?;
// Save the presentation
prs.save_to_file?;
Architecture
graph TB
A[Presentation API] --> B[OPC Package]
B --> C[Parts]
C --> D[PresentationPart]
C --> E[SlidePart]
C --> F[ImagePart]
C --> G[ChartPart]
D --> H[OpenXML Processing]
E --> H
F --> H
G --> H
H --> I[XML Parser/Generator]
B --> J[ZIP Archive]
E --> K[Shape XML Parser]
K --> L[Shapes Module]
L --> M[Hyperlink Support]
Status
🚧 Work in Progress - This library is currently under active development.
Current Status:
- ✅ Core OPC (Open Packaging Convention) support
- ✅ Parts module (all major parts implemented)
- ✅ Shapes module (AutoShape, Picture, Connector, GraphicFrame, GroupShape)
- ✅ 100+ AutoShape types (basic shapes, arrows, flowchart shapes, callouts, action buttons)
- ✅ Hyperlink support for shapes (AutoShape, Picture)
- ✅ Shape XML parsing and generation
- ✅ Text module (TextFrame, Paragraph, Font)
- ✅ Table module
- ✅ Chart module (with axes support)
- ✅ 100+ Chart types (Area, Bar, Column, Line, Pie, Scatter, Bubble, Radar, Stock, Surface, Cone, Cylinder, Pyramid, 3D variants)
- ✅ DML (DrawingML) module
- ✅ 13+ Line dash styles
- ⚠️ XML serialization (in progress)
- ⚠️ Advanced features (placeholders, effects)
Test Coverage: 143 tests passing ✅
Documentation
Examples
Creating a Presentation
use new_presentation;
let mut prs = new_presentation?;
// ... add slides, shapes, etc.
prs.save_to_file?;
Working with Shapes
use ;
let mut shape = new;
shape.set_width; // 1 inch in EMU
shape.set_height;
Working with Hyperlinks
use ;
let mut shape = new;
let mut hlink = with_address;
hlink.set_screen_tip;
shape.set_hyperlink;
Working with Charts
use ;
use ;
let mut chart = new;
chart.set_has_title;
chart.title_mut.unwrap.set_text;
let cat_axis = chart.category_axis_mut;
cat_axis.set_has_title;
let val_axis = chart.value_axis_mut;
val_axis.set_minimum_scale;
val_axis.set_maximum_scale;
Parsing Shapes from XML
use parse_shapes_from_xml;
let xml = r#"<p:spTree>
<p:sp>
<p:nvSpPr>
<p:cNvPr id="2" name="Rectangle 1"/>
</p:nvSpPr>
<p:spPr>
<a:xfrm>
<a:off x="1000000" y="2000000"/>
<a:ext cx="3000000" cy="4000000"/>
</a:xfrm>
</p:spPr>
</p:sp>
</p:spTree>"#;
let shapes = parse_shapes_from_xml?;
Requirements
- Rust 1.70 or later
- Rust edition 2024
License
Licensed under the Apache License, Version 2.0 (LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Acknowledgments
This library is a port of python-pptx by Steve Canny. Many thanks for the excellent reference implementation.