use std::path::{Path, PathBuf};
use office_toolkit::SaveToFile;
use office_toolkit::prelude::*;
use office_toolkit::word::{ColorScheme, FontScheme, Theme};
fn main() -> office_toolkit::Result<()> {
let default_theme_document = Document::new()
.with_theme(Theme::office_default())
.with_paragraph(Paragraph::with_text("Office's built-in default theme."))
.with_paragraph(Paragraph::with_text(
"Cambria for headings, Calibri for body text, the classic Office palette.",
));
let default_path = output_path("docx_theme_default.docx");
default_theme_document.save_to_file(&default_path)?;
println!("Wrote {}", default_path.display());
let custom_colors = ColorScheme::new(
"1B1B1B", "FFFFFF", "0A2540", "F5F5F5", "0A2540", "E8622C", "2E86AB", "6FB98F", "F4A259",
"8E4585", "1155CC", "6B3FA0",
);
let custom_fonts = FontScheme::new("Georgia", "Verdana");
let custom_theme_document = Document::new()
.with_theme(Theme::new("Custom Brand", custom_colors, custom_fonts))
.with_paragraph(Paragraph::with_text("A custom, branded theme."))
.with_paragraph(Paragraph::with_text(
"Georgia for headings, Verdana for body text, a navy/orange palette.",
));
let custom_path = output_path("docx_theme_custom.docx");
custom_theme_document.save_to_file(&custom_path)?;
println!("Wrote {}", custom_path.display());
Ok(())
}
fn output_path(filename: &str) -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../tests-data/output")
.join(filename)
}