Skip to main content

Hyperlink

Struct Hyperlink 

Source
pub struct Hyperlink {
    pub action: HyperlinkAction,
    pub tooltip: Option<String>,
    pub highlight_click: bool,
    pub r_id: Option<String>,
}
Expand description

Hyperlink definition

Fields§

§action: HyperlinkAction

The action to perform when clicked

§tooltip: Option<String>

Tooltip text shown on hover

§highlight_click: bool

Highlight click (visual feedback)

§r_id: Option<String>

Relationship ID (set during XML generation)

Implementations§

Source

pub fn new(action: HyperlinkAction) -> Self

Create a new hyperlink

Source

pub fn url(url: &str) -> Self

Create URL hyperlink

Examples found in repository?
examples/new_elements_demo.rs (line 137)
21fn main() -> Result<(), Box<dyn std::error::Error>> {
22    println!("=== New PPT Elements Demo ===\n");
23
24    // Create slides demonstrating new features
25    let slides = vec![
26        // Slide 1: Title slide
27        SlideContent::new("New PPT Elements in ppt-rs")
28            .add_bullet("18 new chart types")
29            .add_bullet("Connectors between shapes")
30            .add_bullet("Hyperlinks (URL, slide, email)")
31            .add_bullet("Gradient fills")
32            .add_bullet("Video/Audio embedding")
33            .layout(SlideLayout::TitleAndContent),
34
35        // Slide 2: New Chart Types
36        SlideContent::new("New Chart Types")
37            .add_bullet("Area charts (standard, stacked, 100% stacked)")
38            .add_bullet("Scatter charts (markers, lines, smooth)")
39            .add_bullet("Doughnut charts")
40            .add_bullet("Radar charts (standard, filled)")
41            .add_bullet("Bubble charts")
42            .add_bullet("Stock charts (HLC, OHLC)")
43            .add_bullet("Combo charts (bar + line)")
44            .layout(SlideLayout::TitleAndContent),
45
46        // Slide 3: Connector Types
47        SlideContent::new("Connector Types")
48            .add_bullet("Straight connectors")
49            .add_bullet("Elbow (bent) connectors")
50            .add_bullet("Curved connectors")
51            .add_bullet("Arrow heads (Triangle, Stealth, Diamond, Oval)")
52            .add_bullet("Connection sites (Top, Bottom, Left, Right, Corners)")
53            .layout(SlideLayout::TitleAndContent),
54
55        // Slide 4: Hyperlink Types
56        SlideContent::new("Hyperlink Support")
57            .add_bullet("URL links (external websites)")
58            .add_bullet("Slide links (navigate within presentation)")
59            .add_bullet("Email links (mailto:)")
60            .add_bullet("File links (local files)")
61            .add_bullet("Navigation (First, Last, Next, Previous slide)")
62            .layout(SlideLayout::TitleAndContent),
63
64        // Slide 5: Gradient Fills
65        SlideContent::new("Gradient Fill Support")
66            .add_bullet("Linear gradients (horizontal, vertical, diagonal)")
67            .add_bullet("Radial gradients")
68            .add_bullet("Rectangular gradients")
69            .add_bullet("Path gradients")
70            .add_bullet("Preset gradients (Blue, Green, Rainbow, etc.)")
71            .add_bullet("Custom gradient stops with transparency")
72            .layout(SlideLayout::TitleAndContent),
73
74        // Slide 6: Media Support
75        SlideContent::new("Video & Audio Support")
76            .add_bullet("Video formats: MP4, WMV, AVI, MOV, MKV, WebM")
77            .add_bullet("Audio formats: MP3, WAV, WMA, M4A, OGG, FLAC")
78            .add_bullet("Playback options: auto-play, loop, mute")
79            .add_bullet("Volume control")
80            .add_bullet("Start/end time trimming")
81            .layout(SlideLayout::TitleAndContent),
82    ];
83
84    // Generate the PPTX
85    let pptx_data = create_pptx_with_content("New Elements Demo", slides)?;
86
87    // Save to file
88    let output_path = "examples/output/new_elements_demo.pptx";
89    std::fs::create_dir_all("examples/output")?;
90    std::fs::write(output_path, &pptx_data)?;
91
92    println!("✓ Created presentation: {}", output_path);
93    println!("✓ File size: {} bytes", pptx_data.len());
94
95    // Demonstrate API usage
96    println!("\n=== API Examples ===\n");
97
98    // Chart types
99    println!("Chart Types:");
100    let chart_types = [
101        ChartType::Bar,
102        ChartType::BarHorizontal,
103        ChartType::BarStacked,
104        ChartType::Line,
105        ChartType::LineMarkers,
106        ChartType::Pie,
107        ChartType::Doughnut,
108        ChartType::Area,
109        ChartType::AreaStacked,
110        ChartType::Scatter,
111        ChartType::ScatterSmooth,
112        ChartType::Bubble,
113        ChartType::Radar,
114        ChartType::RadarFilled,
115        ChartType::StockHLC,
116        ChartType::Combo,
117    ];
118    for ct in &chart_types {
119        println!("  - {:?} -> {}", ct, ct.xml_element());
120    }
121
122    // Connector example
123    println!("\nConnector Example:");
124    let connector = Connector::elbow(
125        inches_to_emu(1.0), inches_to_emu(1.0),
126        inches_to_emu(5.0), inches_to_emu(3.0),
127    )
128    .with_color("0066CC")
129    .with_end_arrow(ArrowType::Triangle)
130    .connect_start(1, ConnectionSite::Right)
131    .connect_end(2, ConnectionSite::Left);
132    println!("  Type: {:?}", connector.connector_type);
133    println!("  End Arrow: {:?}", connector.end_arrow);
134
135    // Hyperlink example
136    println!("\nHyperlink Examples:");
137    let url_link = Hyperlink::url("https://example.com").with_tooltip("Visit Example");
138    let slide_link = Hyperlink::slide(3);
139    let email_link = Hyperlink::email("test@example.com");
140    println!("  URL: {:?}", url_link.action);
141    println!("  Slide: {:?}", slide_link.action);
142    println!("  Email: {:?}", email_link.action);
143
144    // Gradient example
145    println!("\nGradient Examples:");
146    let blue_gradient = PresetGradients::blue();
147    let rainbow = PresetGradients::rainbow();
148    let custom = GradientFill::linear(GradientDirection::DiagonalDown)
149        .add_stop(ppt_rs::GradientStop::start("FF0000"))
150        .add_stop(ppt_rs::GradientStop::end("0000FF"));
151    println!("  Blue gradient: {} stops", blue_gradient.stops.len());
152    println!("  Rainbow gradient: {} stops", rainbow.stops.len());
153    println!("  Custom gradient: {} stops", custom.stops.len());
154
155    // Video example
156    println!("\nVideo Example:");
157    if let Some(video) = Video::from_file("video.mp4", 0, 0, inches_to_emu(6.0), inches_to_emu(4.0)) {
158        let video = video.with_options(VideoOptions::auto_play().with_loop(true));
159        println!("  Format: {:?}", video.format);
160        println!("  Auto-play: {}", video.options.auto_play);
161        println!("  Loop: {}", video.options.loop_playback);
162    }
163
164    // Audio example
165    println!("\nAudio Example:");
166    if let Some(audio) = Audio::from_file("audio.mp3", 0, 0, inches_to_emu(1.0), inches_to_emu(1.0)) {
167        let audio = audio.with_options(AudioOptions::auto_play().with_play_across_slides(true));
168        println!("  Format: {:?}", audio.format);
169        println!("  Auto-play: {}", audio.options.auto_play);
170        println!("  Play across slides: {}", audio.options.play_across_slides);
171    }
172
173    println!("\n=== Demo Complete ===");
174
175    Ok(())
176}
Source

pub fn slide(slide_num: u32) -> Self

Create slide hyperlink

Examples found in repository?
examples/new_elements_demo.rs (line 138)
21fn main() -> Result<(), Box<dyn std::error::Error>> {
22    println!("=== New PPT Elements Demo ===\n");
23
24    // Create slides demonstrating new features
25    let slides = vec![
26        // Slide 1: Title slide
27        SlideContent::new("New PPT Elements in ppt-rs")
28            .add_bullet("18 new chart types")
29            .add_bullet("Connectors between shapes")
30            .add_bullet("Hyperlinks (URL, slide, email)")
31            .add_bullet("Gradient fills")
32            .add_bullet("Video/Audio embedding")
33            .layout(SlideLayout::TitleAndContent),
34
35        // Slide 2: New Chart Types
36        SlideContent::new("New Chart Types")
37            .add_bullet("Area charts (standard, stacked, 100% stacked)")
38            .add_bullet("Scatter charts (markers, lines, smooth)")
39            .add_bullet("Doughnut charts")
40            .add_bullet("Radar charts (standard, filled)")
41            .add_bullet("Bubble charts")
42            .add_bullet("Stock charts (HLC, OHLC)")
43            .add_bullet("Combo charts (bar + line)")
44            .layout(SlideLayout::TitleAndContent),
45
46        // Slide 3: Connector Types
47        SlideContent::new("Connector Types")
48            .add_bullet("Straight connectors")
49            .add_bullet("Elbow (bent) connectors")
50            .add_bullet("Curved connectors")
51            .add_bullet("Arrow heads (Triangle, Stealth, Diamond, Oval)")
52            .add_bullet("Connection sites (Top, Bottom, Left, Right, Corners)")
53            .layout(SlideLayout::TitleAndContent),
54
55        // Slide 4: Hyperlink Types
56        SlideContent::new("Hyperlink Support")
57            .add_bullet("URL links (external websites)")
58            .add_bullet("Slide links (navigate within presentation)")
59            .add_bullet("Email links (mailto:)")
60            .add_bullet("File links (local files)")
61            .add_bullet("Navigation (First, Last, Next, Previous slide)")
62            .layout(SlideLayout::TitleAndContent),
63
64        // Slide 5: Gradient Fills
65        SlideContent::new("Gradient Fill Support")
66            .add_bullet("Linear gradients (horizontal, vertical, diagonal)")
67            .add_bullet("Radial gradients")
68            .add_bullet("Rectangular gradients")
69            .add_bullet("Path gradients")
70            .add_bullet("Preset gradients (Blue, Green, Rainbow, etc.)")
71            .add_bullet("Custom gradient stops with transparency")
72            .layout(SlideLayout::TitleAndContent),
73
74        // Slide 6: Media Support
75        SlideContent::new("Video & Audio Support")
76            .add_bullet("Video formats: MP4, WMV, AVI, MOV, MKV, WebM")
77            .add_bullet("Audio formats: MP3, WAV, WMA, M4A, OGG, FLAC")
78            .add_bullet("Playback options: auto-play, loop, mute")
79            .add_bullet("Volume control")
80            .add_bullet("Start/end time trimming")
81            .layout(SlideLayout::TitleAndContent),
82    ];
83
84    // Generate the PPTX
85    let pptx_data = create_pptx_with_content("New Elements Demo", slides)?;
86
87    // Save to file
88    let output_path = "examples/output/new_elements_demo.pptx";
89    std::fs::create_dir_all("examples/output")?;
90    std::fs::write(output_path, &pptx_data)?;
91
92    println!("✓ Created presentation: {}", output_path);
93    println!("✓ File size: {} bytes", pptx_data.len());
94
95    // Demonstrate API usage
96    println!("\n=== API Examples ===\n");
97
98    // Chart types
99    println!("Chart Types:");
100    let chart_types = [
101        ChartType::Bar,
102        ChartType::BarHorizontal,
103        ChartType::BarStacked,
104        ChartType::Line,
105        ChartType::LineMarkers,
106        ChartType::Pie,
107        ChartType::Doughnut,
108        ChartType::Area,
109        ChartType::AreaStacked,
110        ChartType::Scatter,
111        ChartType::ScatterSmooth,
112        ChartType::Bubble,
113        ChartType::Radar,
114        ChartType::RadarFilled,
115        ChartType::StockHLC,
116        ChartType::Combo,
117    ];
118    for ct in &chart_types {
119        println!("  - {:?} -> {}", ct, ct.xml_element());
120    }
121
122    // Connector example
123    println!("\nConnector Example:");
124    let connector = Connector::elbow(
125        inches_to_emu(1.0), inches_to_emu(1.0),
126        inches_to_emu(5.0), inches_to_emu(3.0),
127    )
128    .with_color("0066CC")
129    .with_end_arrow(ArrowType::Triangle)
130    .connect_start(1, ConnectionSite::Right)
131    .connect_end(2, ConnectionSite::Left);
132    println!("  Type: {:?}", connector.connector_type);
133    println!("  End Arrow: {:?}", connector.end_arrow);
134
135    // Hyperlink example
136    println!("\nHyperlink Examples:");
137    let url_link = Hyperlink::url("https://example.com").with_tooltip("Visit Example");
138    let slide_link = Hyperlink::slide(3);
139    let email_link = Hyperlink::email("test@example.com");
140    println!("  URL: {:?}", url_link.action);
141    println!("  Slide: {:?}", slide_link.action);
142    println!("  Email: {:?}", email_link.action);
143
144    // Gradient example
145    println!("\nGradient Examples:");
146    let blue_gradient = PresetGradients::blue();
147    let rainbow = PresetGradients::rainbow();
148    let custom = GradientFill::linear(GradientDirection::DiagonalDown)
149        .add_stop(ppt_rs::GradientStop::start("FF0000"))
150        .add_stop(ppt_rs::GradientStop::end("0000FF"));
151    println!("  Blue gradient: {} stops", blue_gradient.stops.len());
152    println!("  Rainbow gradient: {} stops", rainbow.stops.len());
153    println!("  Custom gradient: {} stops", custom.stops.len());
154
155    // Video example
156    println!("\nVideo Example:");
157    if let Some(video) = Video::from_file("video.mp4", 0, 0, inches_to_emu(6.0), inches_to_emu(4.0)) {
158        let video = video.with_options(VideoOptions::auto_play().with_loop(true));
159        println!("  Format: {:?}", video.format);
160        println!("  Auto-play: {}", video.options.auto_play);
161        println!("  Loop: {}", video.options.loop_playback);
162    }
163
164    // Audio example
165    println!("\nAudio Example:");
166    if let Some(audio) = Audio::from_file("audio.mp3", 0, 0, inches_to_emu(1.0), inches_to_emu(1.0)) {
167        let audio = audio.with_options(AudioOptions::auto_play().with_play_across_slides(true));
168        println!("  Format: {:?}", audio.format);
169        println!("  Auto-play: {}", audio.options.auto_play);
170        println!("  Play across slides: {}", audio.options.play_across_slides);
171    }
172
173    println!("\n=== Demo Complete ===");
174
175    Ok(())
176}
Source

pub fn email(address: &str) -> Self

Create email hyperlink

Examples found in repository?
examples/new_elements_demo.rs (line 139)
21fn main() -> Result<(), Box<dyn std::error::Error>> {
22    println!("=== New PPT Elements Demo ===\n");
23
24    // Create slides demonstrating new features
25    let slides = vec![
26        // Slide 1: Title slide
27        SlideContent::new("New PPT Elements in ppt-rs")
28            .add_bullet("18 new chart types")
29            .add_bullet("Connectors between shapes")
30            .add_bullet("Hyperlinks (URL, slide, email)")
31            .add_bullet("Gradient fills")
32            .add_bullet("Video/Audio embedding")
33            .layout(SlideLayout::TitleAndContent),
34
35        // Slide 2: New Chart Types
36        SlideContent::new("New Chart Types")
37            .add_bullet("Area charts (standard, stacked, 100% stacked)")
38            .add_bullet("Scatter charts (markers, lines, smooth)")
39            .add_bullet("Doughnut charts")
40            .add_bullet("Radar charts (standard, filled)")
41            .add_bullet("Bubble charts")
42            .add_bullet("Stock charts (HLC, OHLC)")
43            .add_bullet("Combo charts (bar + line)")
44            .layout(SlideLayout::TitleAndContent),
45
46        // Slide 3: Connector Types
47        SlideContent::new("Connector Types")
48            .add_bullet("Straight connectors")
49            .add_bullet("Elbow (bent) connectors")
50            .add_bullet("Curved connectors")
51            .add_bullet("Arrow heads (Triangle, Stealth, Diamond, Oval)")
52            .add_bullet("Connection sites (Top, Bottom, Left, Right, Corners)")
53            .layout(SlideLayout::TitleAndContent),
54
55        // Slide 4: Hyperlink Types
56        SlideContent::new("Hyperlink Support")
57            .add_bullet("URL links (external websites)")
58            .add_bullet("Slide links (navigate within presentation)")
59            .add_bullet("Email links (mailto:)")
60            .add_bullet("File links (local files)")
61            .add_bullet("Navigation (First, Last, Next, Previous slide)")
62            .layout(SlideLayout::TitleAndContent),
63
64        // Slide 5: Gradient Fills
65        SlideContent::new("Gradient Fill Support")
66            .add_bullet("Linear gradients (horizontal, vertical, diagonal)")
67            .add_bullet("Radial gradients")
68            .add_bullet("Rectangular gradients")
69            .add_bullet("Path gradients")
70            .add_bullet("Preset gradients (Blue, Green, Rainbow, etc.)")
71            .add_bullet("Custom gradient stops with transparency")
72            .layout(SlideLayout::TitleAndContent),
73
74        // Slide 6: Media Support
75        SlideContent::new("Video & Audio Support")
76            .add_bullet("Video formats: MP4, WMV, AVI, MOV, MKV, WebM")
77            .add_bullet("Audio formats: MP3, WAV, WMA, M4A, OGG, FLAC")
78            .add_bullet("Playback options: auto-play, loop, mute")
79            .add_bullet("Volume control")
80            .add_bullet("Start/end time trimming")
81            .layout(SlideLayout::TitleAndContent),
82    ];
83
84    // Generate the PPTX
85    let pptx_data = create_pptx_with_content("New Elements Demo", slides)?;
86
87    // Save to file
88    let output_path = "examples/output/new_elements_demo.pptx";
89    std::fs::create_dir_all("examples/output")?;
90    std::fs::write(output_path, &pptx_data)?;
91
92    println!("✓ Created presentation: {}", output_path);
93    println!("✓ File size: {} bytes", pptx_data.len());
94
95    // Demonstrate API usage
96    println!("\n=== API Examples ===\n");
97
98    // Chart types
99    println!("Chart Types:");
100    let chart_types = [
101        ChartType::Bar,
102        ChartType::BarHorizontal,
103        ChartType::BarStacked,
104        ChartType::Line,
105        ChartType::LineMarkers,
106        ChartType::Pie,
107        ChartType::Doughnut,
108        ChartType::Area,
109        ChartType::AreaStacked,
110        ChartType::Scatter,
111        ChartType::ScatterSmooth,
112        ChartType::Bubble,
113        ChartType::Radar,
114        ChartType::RadarFilled,
115        ChartType::StockHLC,
116        ChartType::Combo,
117    ];
118    for ct in &chart_types {
119        println!("  - {:?} -> {}", ct, ct.xml_element());
120    }
121
122    // Connector example
123    println!("\nConnector Example:");
124    let connector = Connector::elbow(
125        inches_to_emu(1.0), inches_to_emu(1.0),
126        inches_to_emu(5.0), inches_to_emu(3.0),
127    )
128    .with_color("0066CC")
129    .with_end_arrow(ArrowType::Triangle)
130    .connect_start(1, ConnectionSite::Right)
131    .connect_end(2, ConnectionSite::Left);
132    println!("  Type: {:?}", connector.connector_type);
133    println!("  End Arrow: {:?}", connector.end_arrow);
134
135    // Hyperlink example
136    println!("\nHyperlink Examples:");
137    let url_link = Hyperlink::url("https://example.com").with_tooltip("Visit Example");
138    let slide_link = Hyperlink::slide(3);
139    let email_link = Hyperlink::email("test@example.com");
140    println!("  URL: {:?}", url_link.action);
141    println!("  Slide: {:?}", slide_link.action);
142    println!("  Email: {:?}", email_link.action);
143
144    // Gradient example
145    println!("\nGradient Examples:");
146    let blue_gradient = PresetGradients::blue();
147    let rainbow = PresetGradients::rainbow();
148    let custom = GradientFill::linear(GradientDirection::DiagonalDown)
149        .add_stop(ppt_rs::GradientStop::start("FF0000"))
150        .add_stop(ppt_rs::GradientStop::end("0000FF"));
151    println!("  Blue gradient: {} stops", blue_gradient.stops.len());
152    println!("  Rainbow gradient: {} stops", rainbow.stops.len());
153    println!("  Custom gradient: {} stops", custom.stops.len());
154
155    // Video example
156    println!("\nVideo Example:");
157    if let Some(video) = Video::from_file("video.mp4", 0, 0, inches_to_emu(6.0), inches_to_emu(4.0)) {
158        let video = video.with_options(VideoOptions::auto_play().with_loop(true));
159        println!("  Format: {:?}", video.format);
160        println!("  Auto-play: {}", video.options.auto_play);
161        println!("  Loop: {}", video.options.loop_playback);
162    }
163
164    // Audio example
165    println!("\nAudio Example:");
166    if let Some(audio) = Audio::from_file("audio.mp3", 0, 0, inches_to_emu(1.0), inches_to_emu(1.0)) {
167        let audio = audio.with_options(AudioOptions::auto_play().with_play_across_slides(true));
168        println!("  Format: {:?}", audio.format);
169        println!("  Auto-play: {}", audio.options.auto_play);
170        println!("  Play across slides: {}", audio.options.play_across_slides);
171    }
172
173    println!("\n=== Demo Complete ===");
174
175    Ok(())
176}
Source

pub fn with_tooltip(self, tooltip: &str) -> Self

Set tooltip

Examples found in repository?
examples/new_elements_demo.rs (line 137)
21fn main() -> Result<(), Box<dyn std::error::Error>> {
22    println!("=== New PPT Elements Demo ===\n");
23
24    // Create slides demonstrating new features
25    let slides = vec![
26        // Slide 1: Title slide
27        SlideContent::new("New PPT Elements in ppt-rs")
28            .add_bullet("18 new chart types")
29            .add_bullet("Connectors between shapes")
30            .add_bullet("Hyperlinks (URL, slide, email)")
31            .add_bullet("Gradient fills")
32            .add_bullet("Video/Audio embedding")
33            .layout(SlideLayout::TitleAndContent),
34
35        // Slide 2: New Chart Types
36        SlideContent::new("New Chart Types")
37            .add_bullet("Area charts (standard, stacked, 100% stacked)")
38            .add_bullet("Scatter charts (markers, lines, smooth)")
39            .add_bullet("Doughnut charts")
40            .add_bullet("Radar charts (standard, filled)")
41            .add_bullet("Bubble charts")
42            .add_bullet("Stock charts (HLC, OHLC)")
43            .add_bullet("Combo charts (bar + line)")
44            .layout(SlideLayout::TitleAndContent),
45
46        // Slide 3: Connector Types
47        SlideContent::new("Connector Types")
48            .add_bullet("Straight connectors")
49            .add_bullet("Elbow (bent) connectors")
50            .add_bullet("Curved connectors")
51            .add_bullet("Arrow heads (Triangle, Stealth, Diamond, Oval)")
52            .add_bullet("Connection sites (Top, Bottom, Left, Right, Corners)")
53            .layout(SlideLayout::TitleAndContent),
54
55        // Slide 4: Hyperlink Types
56        SlideContent::new("Hyperlink Support")
57            .add_bullet("URL links (external websites)")
58            .add_bullet("Slide links (navigate within presentation)")
59            .add_bullet("Email links (mailto:)")
60            .add_bullet("File links (local files)")
61            .add_bullet("Navigation (First, Last, Next, Previous slide)")
62            .layout(SlideLayout::TitleAndContent),
63
64        // Slide 5: Gradient Fills
65        SlideContent::new("Gradient Fill Support")
66            .add_bullet("Linear gradients (horizontal, vertical, diagonal)")
67            .add_bullet("Radial gradients")
68            .add_bullet("Rectangular gradients")
69            .add_bullet("Path gradients")
70            .add_bullet("Preset gradients (Blue, Green, Rainbow, etc.)")
71            .add_bullet("Custom gradient stops with transparency")
72            .layout(SlideLayout::TitleAndContent),
73
74        // Slide 6: Media Support
75        SlideContent::new("Video & Audio Support")
76            .add_bullet("Video formats: MP4, WMV, AVI, MOV, MKV, WebM")
77            .add_bullet("Audio formats: MP3, WAV, WMA, M4A, OGG, FLAC")
78            .add_bullet("Playback options: auto-play, loop, mute")
79            .add_bullet("Volume control")
80            .add_bullet("Start/end time trimming")
81            .layout(SlideLayout::TitleAndContent),
82    ];
83
84    // Generate the PPTX
85    let pptx_data = create_pptx_with_content("New Elements Demo", slides)?;
86
87    // Save to file
88    let output_path = "examples/output/new_elements_demo.pptx";
89    std::fs::create_dir_all("examples/output")?;
90    std::fs::write(output_path, &pptx_data)?;
91
92    println!("✓ Created presentation: {}", output_path);
93    println!("✓ File size: {} bytes", pptx_data.len());
94
95    // Demonstrate API usage
96    println!("\n=== API Examples ===\n");
97
98    // Chart types
99    println!("Chart Types:");
100    let chart_types = [
101        ChartType::Bar,
102        ChartType::BarHorizontal,
103        ChartType::BarStacked,
104        ChartType::Line,
105        ChartType::LineMarkers,
106        ChartType::Pie,
107        ChartType::Doughnut,
108        ChartType::Area,
109        ChartType::AreaStacked,
110        ChartType::Scatter,
111        ChartType::ScatterSmooth,
112        ChartType::Bubble,
113        ChartType::Radar,
114        ChartType::RadarFilled,
115        ChartType::StockHLC,
116        ChartType::Combo,
117    ];
118    for ct in &chart_types {
119        println!("  - {:?} -> {}", ct, ct.xml_element());
120    }
121
122    // Connector example
123    println!("\nConnector Example:");
124    let connector = Connector::elbow(
125        inches_to_emu(1.0), inches_to_emu(1.0),
126        inches_to_emu(5.0), inches_to_emu(3.0),
127    )
128    .with_color("0066CC")
129    .with_end_arrow(ArrowType::Triangle)
130    .connect_start(1, ConnectionSite::Right)
131    .connect_end(2, ConnectionSite::Left);
132    println!("  Type: {:?}", connector.connector_type);
133    println!("  End Arrow: {:?}", connector.end_arrow);
134
135    // Hyperlink example
136    println!("\nHyperlink Examples:");
137    let url_link = Hyperlink::url("https://example.com").with_tooltip("Visit Example");
138    let slide_link = Hyperlink::slide(3);
139    let email_link = Hyperlink::email("test@example.com");
140    println!("  URL: {:?}", url_link.action);
141    println!("  Slide: {:?}", slide_link.action);
142    println!("  Email: {:?}", email_link.action);
143
144    // Gradient example
145    println!("\nGradient Examples:");
146    let blue_gradient = PresetGradients::blue();
147    let rainbow = PresetGradients::rainbow();
148    let custom = GradientFill::linear(GradientDirection::DiagonalDown)
149        .add_stop(ppt_rs::GradientStop::start("FF0000"))
150        .add_stop(ppt_rs::GradientStop::end("0000FF"));
151    println!("  Blue gradient: {} stops", blue_gradient.stops.len());
152    println!("  Rainbow gradient: {} stops", rainbow.stops.len());
153    println!("  Custom gradient: {} stops", custom.stops.len());
154
155    // Video example
156    println!("\nVideo Example:");
157    if let Some(video) = Video::from_file("video.mp4", 0, 0, inches_to_emu(6.0), inches_to_emu(4.0)) {
158        let video = video.with_options(VideoOptions::auto_play().with_loop(true));
159        println!("  Format: {:?}", video.format);
160        println!("  Auto-play: {}", video.options.auto_play);
161        println!("  Loop: {}", video.options.loop_playback);
162    }
163
164    // Audio example
165    println!("\nAudio Example:");
166    if let Some(audio) = Audio::from_file("audio.mp3", 0, 0, inches_to_emu(1.0), inches_to_emu(1.0)) {
167        let audio = audio.with_options(AudioOptions::auto_play().with_play_across_slides(true));
168        println!("  Format: {:?}", audio.format);
169        println!("  Auto-play: {}", audio.options.auto_play);
170        println!("  Play across slides: {}", audio.options.play_across_slides);
171    }
172
173    println!("\n=== Demo Complete ===");
174
175    Ok(())
176}
Source

pub fn with_highlight_click(self, highlight: bool) -> Self

Set highlight click

Source

pub fn with_r_id(self, r_id: &str) -> Self

Set relationship ID

Trait Implementations§

Source§

fn clone(&self) -> Hyperlink

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more