-
-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathindent.rs
32 lines (30 loc) · 1.03 KB
/
indent.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use docx_rs::*;
pub const DUMMY: &str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
pub fn main() -> Result<(), DocxError> {
let path = std::path::Path::new("./output/indent.docx");
let file = std::fs::File::create(path).unwrap();
Docx::new()
.add_paragraph(Paragraph::new().add_run(Run::new().add_text(DUMMY)).indent(
Some(840),
None,
None,
None,
))
.add_paragraph(Paragraph::new())
.add_paragraph(Paragraph::new().add_run(Run::new().add_text(DUMMY)).indent(
Some(840),
Some(SpecialIndentType::FirstLine(720)),
None,
None,
))
.add_paragraph(Paragraph::new())
.add_paragraph(Paragraph::new().add_run(Run::new().add_text(DUMMY)).indent(
Some(1560),
Some(SpecialIndentType::Hanging(720)),
None,
None,
))
.build()
.pack(file)?;
Ok(())
}