Skip to main content

integrated_example/
integrated_example.rs

1//! Comprehensive integrated example using all PPTX modules
2//!
3//! Run with: cargo run --example integrated_example
4
5use ppt_rs::pptx;
6use ppt_rs::{create_pptx_with_content, SlideContent};
7use std::fs;
8
9fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
10    println!("Integrated PPTX Generation Example\n");
11
12    fs::create_dir_all("examples/output")?;
13
14    println!("1. Creating presentation with Presentation API...");
15    let pres = ppt_rs::Presentation::with_title("Integrated Example")
16        .add_slide(SlideContent::new("Welcome").add_bullet("Point 1"))
17        .add_slide(SlideContent::new("Details").add_bullet("Point 2"));
18    pres.save("examples/output/integrated_example.pptx")?;
19    println!("   Created: examples/output/integrated_example.pptx");
20
21    println!("2. Creating presentation with content API...");
22    let slides = vec![
23        SlideContent::new("Business Report").add_bullet("Q1 Results"),
24        SlideContent::new("Key Metrics").add_bullet("Revenue up 20%"),
25    ];
26    let data = create_pptx_with_content("Business Report", slides)?;
27    fs::write("examples/output/business_report.pptx", data)?;
28    println!("   Created: examples/output/business_report.pptx");
29
30    println!("3. Creating presentation with prelude helpers...");
31    pptx!("Helper Demo")
32        .slide("Shapes", &["Using helpers"])
33        .save("examples/output/helper_demo.pptx")?;
34    println!("   Created: examples/output/helper_demo.pptx");
35
36    println!("\nDone!");
37    Ok(())
38}