1use std::path::{Path, PathBuf};
9
10use office_toolkit::SaveToFile;
11use office_toolkit::prelude::*;
12use office_toolkit::word::{ColorScheme, FontScheme, Theme};
13
14fn main() -> office_toolkit::Result<()> {
15 let default_theme_document = Document::new()
16 .with_theme(Theme::office_default())
17 .with_paragraph(Paragraph::with_text("Office's built-in default theme."))
18 .with_paragraph(Paragraph::with_text(
19 "Cambria for headings, Calibri for body text, the classic Office palette.",
20 ));
21 let default_path = output_path("docx_theme_default.docx");
22 default_theme_document.save_to_file(&default_path)?;
23 println!("Wrote {}", default_path.display());
24
25 let custom_colors = ColorScheme::new(
28 "1B1B1B", "FFFFFF", "0A2540", "F5F5F5", "0A2540", "E8622C", "2E86AB", "6FB98F", "F4A259",
29 "8E4585", "1155CC", "6B3FA0",
30 );
31 let custom_fonts = FontScheme::new("Georgia", "Verdana");
32 let custom_theme_document = Document::new()
33 .with_theme(Theme::new("Custom Brand", custom_colors, custom_fonts))
34 .with_paragraph(Paragraph::with_text("A custom, branded theme."))
35 .with_paragraph(Paragraph::with_text(
36 "Georgia for headings, Verdana for body text, a navy/orange palette.",
37 ));
38 let custom_path = output_path("docx_theme_custom.docx");
39 custom_theme_document.save_to_file(&custom_path)?;
40 println!("Wrote {}", custom_path.display());
41
42 Ok(())
43}
44
45fn output_path(filename: &str) -> PathBuf {
49 Path::new(env!("CARGO_MANIFEST_DIR"))
50 .join("../../tests-data/output")
51 .join(filename)
52}