proper_pptx/
proper_pptx.rs1use std::fs;
6use ppt_rs::prelude::{shapes, colors, ShapeFill};
7use ppt_rs::pptx;
8
9fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10 println!("Generating PPTX files with simplified API...\n");
11
12 fs::create_dir_all("examples/output")?;
14
15 println!("Creating simple.pptx...");
17 pptx!("My Presentation")
18 .slide("Welcome", &["This is a simple presentation", "Created with ppt-rs"])
19 .save("examples/output/simple_proper.pptx")?;
20 println!("✓ Created: examples/output/simple_proper.pptx");
21
22 println!("\nCreating multi_slide.pptx...");
24 pptx!("Multi-Slide Presentation")
25 .title_slide("Introduction")
26 .slide("Agenda", &["Overview", "Details", "Summary", "Q&A"])
27 .slide("Overview", &["Key concepts", "Main features", "Benefits"])
28 .slide("Details", &["Technical specs", "Implementation", "Best practices"])
29 .slide("Summary", &["Key takeaways", "Next steps"])
30 .save("examples/output/multi_slide_proper.pptx")?;
31 println!("✓ Created: examples/output/multi_slide_proper.pptx");
32
33 println!("\nCreating report.pptx...");
35 pptx!("Quarterly Report Q1 2025")
36 .title_slide("Q1 2025 Report")
37 .slide("Highlights", &["Revenue up 15%", "New customers: 500+", "Product launches: 3"])
38 .shapes_slide("Key Metrics", vec![
39 shapes::rect(1.0, 2.0, 2.0, 1.5)
40 .with_fill(ShapeFill::new(colors::CORPORATE_BLUE))
41 .with_text("Revenue"),
42 shapes::rect(4.0, 2.0, 2.0, 1.5)
43 .with_fill(ShapeFill::new(colors::CORPORATE_GREEN))
44 .with_text("Growth"),
45 shapes::rect(7.0, 2.0, 2.0, 1.5)
46 .with_fill(ShapeFill::new(colors::CORPORATE_ORANGE))
47 .with_text("Users"),
48 ])
49 .slide("Next Quarter", &["Goals", "Initiatives", "Timeline"])
50 .save("examples/output/report_proper.pptx")?;
51 println!("✓ Created: examples/output/report_proper.pptx");
52
53 println!("\nCreating training.pptx...");
55 pptx!("Rust Training Course")
56 .title_slide("Learn Rust Programming")
57 .slide("Course Overview", &[
58 "Introduction to Rust",
59 "Ownership and Borrowing",
60 "Structs and Enums",
61 "Error Handling",
62 "Concurrency",
63 ])
64 .slide("Why Rust?", &[
65 "Memory safety without garbage collection",
66 "Zero-cost abstractions",
67 "Fearless concurrency",
68 "Great tooling (cargo, rustfmt, clippy)",
69 ])
70 .shapes_slide("Rust Features", vec![
71 shapes::circle(2.0, 2.5, 1.5)
72 .with_fill(ShapeFill::new(colors::ORANGE))
73 .with_text("Safe"),
74 shapes::circle(5.0, 2.5, 1.5)
75 .with_fill(ShapeFill::new(colors::BLUE))
76 .with_text("Fast"),
77 shapes::circle(8.0, 2.5, 1.5)
78 .with_fill(ShapeFill::new(colors::GREEN))
79 .with_text("Concurrent"),
80 ])
81 .slide("Getting Started", &[
82 "Install rustup",
83 "cargo new my_project",
84 "cargo build && cargo run",
85 ])
86 .save("examples/output/training_proper.pptx")?;
87 println!("✓ Created: examples/output/training_proper.pptx");
88
89 println!("\n✅ All PPTX files generated successfully!");
90 println!("\nGenerated files:");
91
92 for file in &[
94 "examples/output/simple_proper.pptx",
95 "examples/output/multi_slide_proper.pptx",
96 "examples/output/report_proper.pptx",
97 "examples/output/training_proper.pptx",
98 ] {
99 let metadata = fs::metadata(file)?;
100 println!(" ✓ {} ({} bytes)", file, metadata.len());
101 }
102
103 Ok(())
104}