pub struct Presentation { /* private fields */ }Expand description
Represents a PowerPoint presentation
Implementations§
Source§impl Presentation
impl Presentation
Sourcepub fn with_title(title: &str) -> Self
pub fn with_title(title: &str) -> Self
Create a presentation with a title
Examples found in repository?
examples/integrated_example.rs (line 15)
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}Sourcepub fn add_slide(self, slide: SlideContent) -> Self
pub fn add_slide(self, slide: SlideContent) -> Self
Add a slide to the presentation
Examples found in repository?
examples/integrated_example.rs (line 16)
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}Sourcepub fn add_presentation(self, other: Presentation) -> Self
pub fn add_presentation(self, other: Presentation) -> Self
Append slides from another presentation
Sourcepub fn slide_count(&self) -> usize
pub fn slide_count(&self) -> usize
Get the number of slides
Sourcepub fn slides(&self) -> &[SlideContent]
pub fn slides(&self) -> &[SlideContent]
Get the slides in the presentation
Sourcepub fn save<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn save<P: AsRef<Path>>(&self, path: P) -> Result<()>
Save the presentation to a file
Examples found in repository?
examples/integrated_example.rs (line 18)
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}Sourcepub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Self>
Create a presentation from a PPTX file
Sourcepub fn save_as_html<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn save_as_html<P: AsRef<Path>>(&self, path: P) -> Result<()>
Export the presentation to HTML
Sourcepub fn save_as_pdf<P: AsRef<Path>>(&self, output_path: P) -> Result<()>
pub fn save_as_pdf<P: AsRef<Path>>(&self, output_path: P) -> Result<()>
Export the presentation to PDF using LibreOffice
Requires LibreOffice to be installed and available via soffice command.
On macOS, it also checks /Applications/LibreOffice.app/Contents/MacOS/soffice.
Trait Implementations§
Source§impl Clone for Presentation
impl Clone for Presentation
Source§fn clone(&self) -> Presentation
fn clone(&self) -> Presentation
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Presentation
impl Debug for Presentation
Source§impl Default for Presentation
impl Default for Presentation
Source§fn default() -> Presentation
fn default() -> Presentation
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for Presentation
impl RefUnwindSafe for Presentation
impl Send for Presentation
impl Sync for Presentation
impl Unpin for Presentation
impl UnsafeUnpin for Presentation
impl UnwindSafe for Presentation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more