1use ppt_rs::prelude::*;
10use ppt_rs::pptx;
11use ppt_rs::generator::{BulletStyle, ImageBuilder};
12
13fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
14 std::fs::create_dir_all("examples/output")?;
16
17 println!("Creating bullet styles demo...");
19
20 let numbered_slide = SlideContent::new("Numbered List")
22 .with_bullet_style(BulletStyle::Number)
23 .add_bullet("First step")
24 .add_bullet("Second step")
25 .add_bullet("Third step")
26 .add_bullet("Fourth step");
27
28 let lettered_slide = SlideContent::new("Lettered List")
30 .add_lettered("Option A")
31 .add_lettered("Option B")
32 .add_lettered("Option C");
33
34 let roman_slide = SlideContent::new("Roman Numerals")
36 .with_bullet_style(BulletStyle::RomanUpper)
37 .add_bullet("Chapter I")
38 .add_bullet("Chapter II")
39 .add_bullet("Chapter III");
40
41 let mixed_slide = SlideContent::new("Mixed Bullets")
43 .add_bullet("Main point")
44 .add_sub_bullet("Supporting detail 1")
45 .add_sub_bullet("Supporting detail 2")
46 .add_bullet("Another main point")
47 .add_sub_bullet("More details");
48
49 let custom_slide = SlideContent::new("Custom Bullets")
51 .add_styled_bullet("Star bullet", BulletStyle::Custom('★'))
52 .add_styled_bullet("Arrow bullet", BulletStyle::Custom('→'))
53 .add_styled_bullet("Check bullet", BulletStyle::Custom('✓'))
54 .add_styled_bullet("Diamond bullet", BulletStyle::Custom('◆'));
55
56 let bullet_demo = pptx!("Bullet Styles Demo")
57 .title_slide("Bullet Styles - Demonstrating various list formats")
58 .content_slide(numbered_slide)
59 .content_slide(lettered_slide)
60 .content_slide(roman_slide)
61 .content_slide(mixed_slide)
62 .content_slide(custom_slide)
63 .build()?;
64
65 std::fs::write("examples/output/bullet_styles.pptx", bullet_demo)?;
66 println!(" ✓ Created examples/output/bullet_styles.pptx");
67
68 println!("Creating text formatting demo...");
70
71 let text_demo = pptx!("Text Formatting Demo")
72 .title_slide("Text Formatting - Strikethrough, highlight, subscript, superscript")
73 .slide("Text Styles", &[
74 "Normal text for comparison",
75 "This demonstrates various formatting options",
76 "Use TextFormat for rich text styling",
77 ])
78 .slide("Font Size Presets", &[
79 &format!("TITLE: {}pt - For main titles", font_sizes::TITLE),
80 &format!("SUBTITLE: {}pt - For subtitles", font_sizes::SUBTITLE),
81 &format!("HEADING: {}pt - For section headers", font_sizes::HEADING),
82 &format!("BODY: {}pt - For regular content", font_sizes::BODY),
83 &format!("SMALL: {}pt - For smaller text", font_sizes::SMALL),
84 &format!("CAPTION: {}pt - For captions", font_sizes::CAPTION),
85 ])
86 .slide("Text Effects", &[
87 "Strikethrough: For deleted text",
88 "Highlight: For emphasized text",
89 "Subscript: H₂O style formatting",
90 "Superscript: x² style formatting",
91 ])
92 .build()?;
93
94 std::fs::write("examples/output/text_formatting.pptx", text_demo)?;
95 println!(" ✓ Created examples/output/text_formatting.pptx");
96
97 println!("Creating image demo...");
99
100 let red_pixel_base64 = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8DwHwAFBQIAX8jx0gAAAABJRU5ErkJggg==";
102
103 let img = ImageBuilder::from_base64(red_pixel_base64, inches(2.0), inches(2.0), "PNG")
105 .position(inches(4.0), inches(3.0))
106 .build();
107
108 let image_slide = SlideContent::new("Image from Base64")
109 .add_bullet("Images can be loaded from base64 encoded data")
110 .add_bullet("Useful for embedding images without file access")
111 .add_bullet("Supports PNG, JPEG, GIF formats")
112 .add_image(img);
113
114 let image_demo = pptx!("Image Features Demo")
115 .title_slide("Image Features - Loading images from various sources")
116 .content_slide(image_slide)
117 .slide("Image Sources", &[
118 "Image::new(filename) - From file path",
119 "Image::from_base64(data) - From base64 string",
120 "Image::from_bytes(data) - From raw bytes",
121 "ImageBuilder for fluent API",
122 ])
123 .build()?;
124
125 std::fs::write("examples/output/image_features.pptx", image_demo)?;
126 println!(" ✓ Created examples/output/image_features.pptx");
127
128 println!("Creating themes demo...");
130
131 let all_themes = themes::all();
132 let theme_info: Vec<String> = all_themes.iter().map(|t| {
133 format!("{}: Primary={}, Accent={}", t.name, t.primary, t.accent)
134 }).collect();
135
136 let themes_demo = pptx!("Theme Colors Demo")
137 .title_slide("Theme Colors - Predefined color palettes")
138 .slide("Available Themes", &theme_info.iter().map(|s| s.as_str()).collect::<Vec<_>>())
139 .slide("Color Constants", &[
140 &format!("Material Red: {}", colors::MATERIAL_RED),
141 &format!("Material Blue: {}", colors::MATERIAL_BLUE),
142 &format!("Material Green: {}", colors::MATERIAL_GREEN),
143 &format!("Carbon Blue 60: {}", colors::CARBON_BLUE_60),
144 &format!("Carbon Gray 100: {}", colors::CARBON_GRAY_100),
145 ])
146 .build()?;
147
148 std::fs::write("examples/output/themes_demo.pptx", themes_demo)?;
149 println!(" ✓ Created examples/output/themes_demo.pptx");
150
151 println!("Creating complete feature showcase...");
153
154 let showcase = pptx!("ppt-rs v0.2.1 Features")
155 .title_slide("New Features in ppt-rs v0.2.1")
156 .slide("Bullet Formatting", &[
157 "BulletStyle::Number - 1, 2, 3...",
158 "BulletStyle::LetterLower/Upper - a, b, c / A, B, C",
159 "BulletStyle::RomanLower/Upper - i, ii, iii / I, II, III",
160 "BulletStyle::Custom(char) - Any custom character",
161 "Sub-bullets with indentation",
162 ])
163 .slide("Text Enhancements", &[
164 "TextFormat::strikethrough() - Strike through text",
165 "TextFormat::highlight(color) - Background highlight",
166 "TextFormat::subscript() - H₂O style",
167 "TextFormat::superscript() - x² style",
168 "font_sizes module with presets",
169 ])
170 .slide("Image Loading", &[
171 "Image::from_base64() - Base64 encoded images",
172 "Image::from_bytes() - Raw byte arrays",
173 "ImageSource enum for flexible handling",
174 "Built-in base64 decoder",
175 ])
176 .slide("Templates", &[
177 "templates::business_proposal()",
178 "templates::status_report()",
179 "templates::training_material()",
180 "templates::technical_doc()",
181 "templates::simple()",
182 ])
183 .slide("Themes & Colors", &[
184 "themes::CORPORATE, MODERN, VIBRANT, DARK",
185 "themes::NATURE, TECH, CARBON",
186 "colors module with Material Design colors",
187 "colors module with IBM Carbon colors",
188 ])
189 .build()?;
190
191 std::fs::write("examples/output/feature_showcase.pptx", showcase)?;
192 println!(" ✓ Created examples/output/feature_showcase.pptx");
193
194 println!("\n✅ All demos created successfully!");
195 println!(" Check examples/output/ for the generated files.");
196
197 Ok(())
198}
199