🚀Easy Docx Template
Create docx templates
Usage/Examples
Example 1:
fn main() {
let mut docx = DOCX::new("example/test.docx".to_string());
docx.read();
docx.add_placeholder("{{exam.title}}", "Mathexam");
docx.add_placeholder("{{exam.variant}}", "1 variant");
docx.add_placeholder("{{exam.subject}}", "Math");
docx.add_placeholder("{{exam.level}}", "1-A form");
docx.init_placeholders();
docx.save("output.docx");
println!("✅ File saved: output.docx")
}
Example 2(Loading data from json):
fn main() {
let mut docx = DOCX::new("example/test.docx".to_string());
docx.read();
docx.add_placeholders_from_json(r#"{
"exam": {
"level": "form 2-A",
"variant": "1 variant",
"title": "Math exam",
"subject": "math"
}
}"#);
docx.init_placeholders();
docx.save("output.docx");
println!("✅ File saved: output.docx")
}
Warning! Image placeholders are initialized when the final file is saved.
Example 3(Add image placeholder)
fn test_1() {
let mut docx = DOCX::new("example/test.docx".to_string());
docx.read();
docx.add_placeholders_from_json(r#"{
"exam": {
"level": "form 2-A",
"variant": "1 variant",
"title": "Math exam",
"subject": "math"
}
}"#);
docx.add_image_placeholder("image1.jpeg", "example/replace_image1.png");
docx.init_placeholders();
docx.save("output.docx");
println!("✅ File saved: output.docx")
}

Roadmap
- Add block constructions
- optimize
- Add list and table support
🔗Author
Created by Dmitry Dzhugov
morfyalt@proton.me