1use ppt_rs::templates::{
11 self, ProposalContent, StatusContent, TrainingContent, TechnicalContent,
12};
13use ppt_rs::prelude::*;
14use ppt_rs::pptx;
15
16fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
17 println!("Creating business proposal...");
19 let proposal = templates::business_proposal(
20 "Q4 Budget Proposal 2025",
21 "Finance Team",
22 ProposalContent {
23 executive_summary: vec![
24 "Requesting $500,000 for digital transformation",
25 "Expected ROI of 300% within 18 months",
26 "Aligns with corporate strategic goals",
27 ],
28 problem: vec![
29 "Legacy systems causing 40% productivity loss",
30 "Customer satisfaction declining due to slow response",
31 "Competitors gaining market share with modern solutions",
32 ],
33 solution: vec![
34 "Implement cloud-native infrastructure",
35 "Deploy AI-powered customer service",
36 "Modernize internal workflows with automation",
37 ],
38 timeline: vec![
39 ("Phase 1: Planning", "Q1 2025"),
40 ("Phase 2: Development", "Q2-Q3 2025"),
41 ("Phase 3: Deployment", "Q4 2025"),
42 ("Phase 4: Optimization", "Q1 2026"),
43 ],
44 budget: vec![
45 ("Infrastructure", "$200,000"),
46 ("Development", "$150,000"),
47 ("Training", "$50,000"),
48 ("Contingency", "$100,000"),
49 ],
50 next_steps: vec![
51 "Executive approval by Jan 15",
52 "Vendor selection by Feb 1",
53 "Team assembly by Feb 15",
54 "Kickoff meeting Mar 1",
55 ],
56 },
57 )?;
58 std::fs::write("examples/output/proposal.pptx", proposal)?;
59 println!(" ✓ Created examples/output/proposal.pptx");
60
61 println!("Creating status report...");
63 let status = templates::status_report(
64 "Project Alpha - Weekly Status",
65 "Week of December 23, 2025",
66 StatusContent {
67 summary: vec![
68 "Sprint 12 completed on schedule",
69 "All critical features delivered",
70 "On track for Q1 release",
71 ],
72 completed: vec![
73 "User authentication module",
74 "Dashboard redesign",
75 "API performance optimization",
76 "Security audit remediation",
77 ],
78 in_progress: vec![
79 "Mobile responsive layouts",
80 "Export functionality",
81 "Integration testing",
82 ],
83 blocked: vec![
84 "Third-party API access pending approval",
85 ],
86 next_week: vec![
87 "Complete mobile layouts",
88 "Begin UAT testing",
89 "Prepare deployment documentation",
90 ],
91 metrics: vec![
92 ("Velocity", "42 story points"),
93 ("Bug Count", "3 (down from 12)"),
94 ("Test Coverage", "87%"),
95 ("Sprint Burndown", "On track"),
96 ],
97 },
98 )?;
99 std::fs::write("examples/output/status_report.pptx", status)?;
100 println!(" ✓ Created examples/output/status_report.pptx");
101
102 println!("Creating training material...");
104 let training = templates::training_material(
105 "Introduction to Rust Programming",
106 "DevOps Academy",
107 TrainingContent {
108 objectives: vec![
109 "Understand Rust's ownership model",
110 "Write safe, concurrent code",
111 "Build and test Rust applications",
112 "Integrate Rust with existing systems",
113 ],
114 modules: vec![
115 ("Module 1: Getting Started", vec![
116 "Installing Rust toolchain",
117 "Hello World program",
118 "Cargo basics",
119 "VS Code setup",
120 ]),
121 ("Module 2: Ownership & Borrowing", vec![
122 "Stack vs Heap",
123 "Move semantics",
124 "References and borrowing",
125 "Lifetimes basics",
126 ]),
127 ("Module 3: Error Handling", vec![
128 "Result and Option types",
129 "Pattern matching",
130 "The ? operator",
131 "Custom error types",
132 ]),
133 ],
134 exercises: vec![
135 "Build a CLI calculator",
136 "Implement a linked list",
137 "Create a REST API client",
138 "Write unit tests for all modules",
139 ],
140 summary: vec![
141 "Rust provides memory safety without garbage collection",
142 "Ownership model prevents data races at compile time",
143 "Cargo makes dependency management easy",
144 "Strong type system catches errors early",
145 ],
146 },
147 )?;
148 std::fs::write("examples/output/training.pptx", training)?;
149 println!(" ✓ Created examples/output/training.pptx");
150
151 println!("Creating technical documentation...");
153 let tech_doc = templates::technical_doc(
154 "ppt-rs Library Architecture",
155 "0.2.0",
156 TechnicalContent {
157 overview: vec![
158 "Rust library for PowerPoint generation",
159 "ECMA-376 Office Open XML compliant",
160 "Zero runtime dependencies on Microsoft Office",
161 "Cross-platform support",
162 ],
163 architecture: vec![
164 "Layered architecture: API → Generator → Parts → OPC",
165 "Trait-based design for extensibility",
166 "Builder pattern for fluent API",
167 "Modular components for maintainability",
168 ],
169 components: vec![
170 ("Generator Module", vec![
171 "SlideContent - Slide builder",
172 "Shape - Shape creation",
173 "Table - Table builder",
174 "Chart - Chart builder",
175 ]),
176 ("Parts Module", vec![
177 "SlidePart - Individual slides",
178 "ImagePart - Embedded images",
179 "ChartPart - Embedded charts",
180 "MediaPart - Video/audio",
181 ]),
182 ("CLI Module", vec![
183 "md2ppt - Markdown conversion",
184 "validate - PPTX validation",
185 "create - Quick presentation",
186 ]),
187 ],
188 api_examples: vec![
189 ("create_pptx()", "Create basic presentation"),
190 ("SlideContent::new()", "Build slide content"),
191 ("Shape::new()", "Create shapes"),
192 ("TableBuilder::new()", "Build tables"),
193 ],
194 best_practices: vec![
195 "Use prelude module for simplified API",
196 "Leverage templates for common use cases",
197 "Use layout helpers for consistent positioning",
198 "Test presentations with validation command",
199 ],
200 },
201 )?;
202 std::fs::write("examples/output/tech_doc.pptx", tech_doc)?;
203 println!(" ✓ Created examples/output/tech_doc.pptx");
204
205 println!("Creating simple presentation...");
207 let simple = templates::simple("Quick Presentation", &[
208 ("Welcome", &[
209 "Hello, World!",
210 "This is a simple presentation",
211 "Created with ppt-rs templates",
212 ]),
213 ("Features", &[
214 "Easy to use API",
215 "Multiple templates",
216 "Theme support",
217 ]),
218 ("Conclusion", &[
219 "Try ppt-rs today!",
220 "Visit github.com/yingkitw/ppt-rs",
221 ]),
222 ])?;
223 std::fs::write("examples/output/simple.pptx", simple)?;
224 println!(" ✓ Created examples/output/simple.pptx");
225
226 println!("Creating theme showcase...");
228 let theme_pptx = pptx!("Theme Showcase")
229 .slide("Available Themes", &[
230 &format!("Corporate: Primary {} / Accent {}",
231 themes::CORPORATE.primary, themes::CORPORATE.accent),
232 &format!("Modern: Primary {} / Accent {}",
233 themes::MODERN.primary, themes::MODERN.accent),
234 &format!("Vibrant: Primary {} / Accent {}",
235 themes::VIBRANT.primary, themes::VIBRANT.accent),
236 &format!("Dark: Primary {} / Accent {}",
237 themes::DARK.primary, themes::DARK.accent),
238 &format!("Carbon: Primary {} / Accent {}",
239 themes::CARBON.primary, themes::CARBON.accent),
240 ])
241 .slide("Material Colors", &[
242 &format!("Red: {}", colors::MATERIAL_RED),
243 &format!("Blue: {}", colors::MATERIAL_BLUE),
244 &format!("Green: {}", colors::MATERIAL_GREEN),
245 &format!("Orange: {}", colors::MATERIAL_ORANGE),
246 ])
247 .slide("Carbon Colors", &[
248 &format!("Blue 60: {}", colors::CARBON_BLUE_60),
249 &format!("Green 50: {}", colors::CARBON_GREEN_50),
250 &format!("Gray 100: {}", colors::CARBON_GRAY_100),
251 ])
252 .build()?;
253 std::fs::write("examples/output/themes.pptx", theme_pptx)?;
254 println!(" ✓ Created examples/output/themes.pptx");
255
256 println!("Creating layout demo...");
258 let grid_positions = layouts::grid(2, 3, 1500000, 1000000);
259 let mut grid_shapes = Vec::new();
260 let theme_colors = [
261 themes::CORPORATE.primary,
262 themes::MODERN.primary,
263 themes::VIBRANT.primary,
264 themes::DARK.primary,
265 themes::NATURE.primary,
266 themes::TECH.primary,
267 ];
268
269 for (i, (x, y)) in grid_positions.iter().enumerate() {
270 grid_shapes.push(
271 shapes::rect_emu(*x, *y, 1400000, 900000)
272 .with_fill(ShapeFill::new(theme_colors[i]))
273 .with_text(&format!("Theme {}", i + 1))
274 );
275 }
276
277 let layout_pptx = pptx!("Layout Helpers Demo")
278 .shapes_slide("Grid Layout (2x3)", grid_shapes)
279 .slide("Layout Features", &[
280 "layouts::grid() - Create grid positions",
281 "layouts::center() - Center shapes on slide",
282 "layouts::stack_horizontal() - Horizontal stacking",
283 "layouts::distribute_horizontal() - Even distribution",
284 ])
285 .build()?;
286 std::fs::write("examples/output/layouts.pptx", layout_pptx)?;
287 println!(" ✓ Created examples/output/layouts.pptx");
288
289 println!("\n✅ All template demos created successfully!");
290 println!(" Check examples/output/ for the generated files.");
291
292 Ok(())
293}
294