docx-rs/docx-core/examples/indent.rs

25 lines
789 B
Rust
Raw Normal View History

2019-11-11 09:48:28 +02:00
use docx_core::*;
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() {
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(DUMMY)).indent(840, None))
.add_paragraph(Paragraph::new())
.add_paragraph(
Paragraph::new()
.add_run(Run::new(DUMMY))
.indent(840, Some(SpecialIndentType::FirstLine(720))),
)
.add_paragraph(Paragraph::new())
.add_paragraph(
Paragraph::new()
.add_run(Run::new(DUMMY))
.indent(1560, Some(SpecialIndentType::Hanging(720))),
)
.build()
.pack(file);
}