### Generate Presentation using ppt-rs Library (Simple API) Source: https://crates.io/crates/ppt-rs/index This Rust code example utilizes the `ppt-rs` library's simple API to programmatically create a PowerPoint presentation. It demonstrates adding a title slide, a bulleted slide, and a slide with shapes, including basic shape customization with color and text. The `build()` method finalizes the presentation, which is then saved to a file. This requires the `ppt_rs` crate to be added as a dependency. ```rust use ppt_rs::prelude::*; fn main() -> std::result::Result<(), Box> { // Quick presentation with macros let pptx = pptx!("My Presentation") .title_slide("Welcome", "Introduction to ppt-rs") .slide("Key Points", vec!["Point 1", "Point 2", "Point 3"]) .shapes_slide("Shapes", vec![ shapes::rect(inches(1.0), inches(2.0), inches(2.0), inches(1.0)) .with_fill(ShapeFill::new(colors::BLUE)) .with_text("Hello"), ]) .build()?; std::fs::write("output.pptx", pptx)?; Ok(()) } ``` -------------------------------- ### Generate PPTX with Charts using Rust Source: https://crates.io/crates/ppt-rs/0.1 Provides an example of creating charts within PPTX presentations using the `ChartBuilder` from `ppt_rs::generator`. It demonstrates how to define chart titles, types, categories, and series data. ```rust use ppt_rs::generator::{ChartBuilder, ChartType, ChartSeries}; let chart = ChartBuilder::new("Sales", ChartType::Bar) .categories(vec!["Q1", "Q2", "Q3"]) .add_series(ChartSeries::new("2023", vec![100.0, 150.0, 120.0])) .build(); ``` -------------------------------- ### Convert Markdown to PowerPoint using CLI Source: https://crates.io/crates/ppt-rs/index This snippet demonstrates how to use the `pptcli` command-line tool to convert a Markdown file into a PowerPoint (.pptx) presentation. It shows basic conversion and options for specifying the output file name and presentation title. No external dependencies are required beyond the `ppt-rs` installation. ```bash # Auto-generates slides.pptx pptcli md2ppt slides.md # Or specify output pptcli md2ppt slides.md presentation.pptx # With custom title pptcli md2ppt slides.md --title "My Presentation" ``` -------------------------------- ### Generate PPTX with Connectors using Rust Source: https://crates.io/crates/ppt-rs/0.1 Demonstrates how to add connectors between shapes in PPTX presentations using the `Connector` struct from `ppt_rs::generator`. Examples show straight and elbow connectors with various line styles, arrow types, and sizes. ```rust use ppt_rs::generator::{Connector, ConnectorLine, ArrowType, ArrowSize, LineDash}; // Straight connector with arrow let conn = Connector::straight(1000000, 1000000, 3000000, 1000000) .with_line(ConnectorLine::new("1565C0", 25400)) .with_end_arrow(ArrowType::Triangle) .with_arrow_size(ArrowSize::Large); // Elbow connector with dashed line let elbow = Connector::elbow(1000000, 2000000, 3000000, 3000000) .with_line(ConnectorLine::new("2E7D32", 19050).with_dash(LineDash::Dash)) .with_arrows(ArrowType::Oval, ArrowType::Stealth); ``` -------------------------------- ### Generate PPTX with Shapes using Rust Source: https://crates.io/crates/ppt-rs/0.1 Illustrates the creation of various shapes in PPTX files using the `Shape` struct from `ppt_rs::generator`. Examples include simple shapes with solid fills, shapes with gradient fills, and shapes with transparency and borders. ```rust use ppt_rs::generator::{Shape, ShapeType, ShapeFill, ShapeLine}; use ppt_rs::generator::shapes::{GradientFill, GradientDirection}; // Simple shape with solid fill let shape = Shape::new(ShapeType::Rectangle, 0, 0, 1000000, 500000) .with_fill(ShapeFill::new("FF0000")) .with_text("Hello"); // Shape with gradient fill let gradient_shape = Shape::new(ShapeType::RoundedRectangle, 0, 0, 2000000, 1000000) .with_gradient(GradientFill::linear("1565C0", "42A5F5", GradientDirection::Horizontal)) .with_text("Gradient"); // Shape with transparency let transparent = Shape::new(ShapeType::Ellipse, 0, 0, 1500000, 1500000) .with_fill(ShapeFill::new("4CAF50").with_transparency(50)) .with_line(ShapeLine::new("1B5E20", 25400)); ``` -------------------------------- ### Show PPTX File Information with CLI Source: https://crates.io/crates/ppt-rs/0.1 Utilizes the `pptcli` command-line tool to display information about a given PPTX file. ```bash pptcli info presentation.pptx ``` -------------------------------- ### Generate PPTX with Tables using Rust Source: https://crates.io/crates/ppt-rs/0.1 Shows how to create PPTX presentations with tables using the `TableBuilder` from `ppt_rs::generator`. It covers creating both simple and styled tables with custom formatting for cells, rows, and positioning. ```rust use ppt_rs::generator::{SlideContent, TableBuilder, TableRow, TableCell, create_pptx_with_content}; // Simple table let table = TableBuilder::new(vec![2000000, 2000000]) .add_simple_row(vec!["Name", "Status"]) .add_simple_row(vec!["Alice", "Active"]) .build(); // Styled table with formatting let styled_table = TableBuilder::new(vec![2000000, 2000000, 2000000]) .add_row(TableRow::new(vec![ TableCell::new("Header 1").bold().background_color("4472C4").text_color("FFFFFF"), TableCell::new("Header 2").bold().background_color("4472C4").text_color("FFFFFF"), TableCell::new("Header 3").bold().background_color("4472C4").text_color("FFFFFF"), ])) .add_row(TableRow::new(vec![ TableCell::new("Data 1"), TableCell::new("Data 2").italic(), TableCell::new("Data 3").text_color("2E7D32"), ])) .position(500000, 1500000) .build(); let slides = vec![ SlideContent::new("Data").table(styled_table), ]; ``` -------------------------------- ### Generate PPTX using ppt-rs Simple API in Rust Source: https://crates.io/crates/ppt-rs/0.1 This Rust code snippet demonstrates the simple API of the ppt-rs library for creating a PowerPoint presentation. It utilizes a builder pattern to add a title slide, a bulleted slide, and a slide with shapes. The presentation is then built and written to a file named 'output.pptx'. ```rust use ppt_rs::prelude::*; fn main() -> std::result::Result<(), Box> { // Quick presentation with macros let pptx = pptx!("My Presentation") .title_slide("Welcome", "Introduction to ppt-rs") .slide("Key Points", vec!["Point 1", "Point 2", "Point 3"]) .shapes_slide("Shapes", vec![ shapes::rect(inches(1.0), inches(2.0), inches(2.0), inches(1.0)) .with_fill(ShapeFill::new(colors::BLUE)) .with_text("Hello"), ]) .build()?; std::fs::write("output.pptx", pptx)?; Ok(()) } ``` -------------------------------- ### Generate Simple and Styled Tables in Rust Source: https://crates.io/crates/ppt-rs/index Create tables within PPTX presentations using the `TableBuilder` from `ppt-rs`. This includes building simple tables with basic rows and columns, as well as styled tables with specific formatting like bold text, background colors, and text colors. ```rust use ppt_rs::generator::{SlideContent, TableBuilder, TableRow, TableCell, create_pptx_with_content}; // Simple table let table = TableBuilder::new(vec![2000000, 2000000]) .add_simple_row(vec!["Name", "Status"]) .add_simple_row(vec!["Alice", "Active"]) .build(); // Styled table with formatting let styled_table = TableBuilder::new(vec![2000000, 2000000, 2000000]) .add_row(TableRow::new(vec[ TableCell::new("Header 1").bold().background_color("4472C4").text_color("FFFFFF"), TableCell::new("Header 2").bold().background_color("4472C4").text_color("FFFFFF"), TableCell::new("Header 3").bold().background_color("4472C4").text_color("FFFFFF"), ])) .add_row(TableRow::new(vec[ TableCell::new("Data 1"), TableCell::new("Data 2").italic(), TableCell::new("Data 3").text_color("2E7D32"), ])) .position(500000, 1500000) .build(); let slides = vec![ SlideContent::new("Data").table(styled_table), ]; ``` -------------------------------- ### Convert Markdown to PPTX using pptcli Source: https://crates.io/crates/ppt-rs/0.1 This command-line interface (CLI) tool converts Markdown files into PowerPoint (.pptx) presentations. It takes the input Markdown file and an optional output file name. A custom title can also be specified. ```bash # Auto-generates slides.pptx pptcli md2ppt slides.md # Or specify output pptcli md2ppt slides.md presentation.pptx # With custom title pptcli md2ppt slides.md --title "My Presentation" ``` -------------------------------- ### Generate PPTX using ppt-rs Full API in Rust Source: https://crates.io/crates/ppt-rs/0.1 This Rust code snippet showcases the full API of the ppt-rs library for creating PowerPoint presentations. It defines slides with content, including titles and bullet points, and then uses the `create_pptx_with_content` function to generate the PPTX file, which is subsequently written to 'output.pptx'. ```rust use ppt_rs::generator::{SlideContent, create_pptx_with_content}; fn main() -> std::result::Result<(), Box> { let slides = vec![ SlideContent::new("Introduction") .add_bullet("Welcome") .add_bullet("Agenda"), SlideContent::new("Key Points") .add_bullet("Point 1") .add_bullet("Point 2"), ]; let pptx = create_pptx_with_content("My Presentation", slides)?; std::fs::write("output.pptx", pptx)?; Ok(()) } ``` -------------------------------- ### Repair PPTX Files with Rust API Source: https://crates.io/crates/ppt-rs/0.1 Demonstrates how to repair damaged or corrupted PPTX files using the `PptxRepair` struct from the `ppt_rs::oxml::repair` module. It includes steps for opening, validating, repairing, and saving the presentation. The process identifies various issues like missing parts, malformed XML, and broken references. ```rust use ppt_rs::oxml::repair::PptxRepair; // Open and validate let mut repair = PptxRepair::open("damaged.pptx")?; let issues = repair.validate(); println!("Found {} issues", issues.len()); for issue in &issues { println!(" - {} (severity: {})", issue.description(), issue.severity()); } // Repair and save let result = repair.repair(); if result.is_valid { repair.save("repaired.pptx")?; println!("File repaired successfully!"); } ``` -------------------------------- ### Add ppt-rs to Cargo.toml Source: https://crates.io/crates/ppt-rs/0.1 Shows the dependency declaration required to include the `ppt-rs` crate in a Rust project's `Cargo.toml` file. ```toml [dependencies] ppt-rs = "0.1" ``` -------------------------------- ### Validate PPTX Files with CLI Source: https://crates.io/crates/ppt-rs/0.1 Uses the `pptcli` command-line tool to validate a PPTX file for ECMA-376 compliance. This process checks ZIP archive integrity, presence of required XML files, XML validity, and the relationships structure. ```bash pptcli validate presentation.pptx ``` -------------------------------- ### Repair Damaged PPTX Files in Rust Source: https://crates.io/crates/ppt-rs/index Utilize the `PptxRepair` struct from the `ppt-rs` crate to open, validate, and repair damaged or corrupted PPTX files. The process involves checking for various issues like missing parts, malformed XML, and broken references, then saving the repaired file. ```rust use ppt_rs::oxml::repair::PptxRepair; // Open and validate let mut repair = PptxRepair::open("damaged.pptx")?; let issues = repair.validate(); println!("Found {} issues", issues.len()); for issue in &issues { println!(" - {} (severity: {})", issue.description(), issue.severity()); } // Repair and save let result = repair.repair(); if result.is_valid { repair.save("repaired.pptx")?; println!("File repaired successfully!"); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.