use std::path::{Path, PathBuf};
use office_toolkit::drawing::{ShapeProperties, TextBody, TextParagraph, TextRun, Transform2D};
use office_toolkit::powerpoint::{AutoShape, Shape};
use office_toolkit::prelude::*;
use office_toolkit::{OpenFile, SaveToFile};
fn main() -> office_toolkit::Result<()> {
let path = output_path("hello_world.pptx");
let text_box = AutoShape::new(2, "Hello box")
.with_properties(
ShapeProperties::new().with_transform(
Transform2D::new()
.with_offset(838_200, 1_365_250)
.with_extent(7_772_400, 1_200_150),
),
)
.with_text_body(
TextBody::new()
.with_paragraph(TextParagraph::new().with_run(TextRun::text("Hello, world!"))),
);
let presentation =
Presentation::new().with_slide(Slide::new().with_shape(Shape::AutoShape(text_box)));
presentation.save_to_file(&path)?;
println!("Wrote {}", path.display());
let reopened = Presentation::open_file(&path)?;
println!("Slide count: {}", reopened.slides.len());
Ok(())
}
fn output_path(filename: &str) -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../tests-data/output")
.join(filename)
}