File: section.rs

package info (click to toggle)
rust-docx-rs 0.4.19-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,124 kB
  • sloc: xml: 194; makefile: 7
file content (21 lines) | stat: -rw-r--r-- 769 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use docx_rs::*;

pub fn main() -> Result<(), DocxError> {
    let path = std::path::Path::new("./output/examples/section.docx");
    let file = std::fs::File::create(path).unwrap();
    let section = Section::new()
        .add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
        .page_size(PageSize::new().size(10000, 10000))
        .page_orient(PageOrientationType::Landscape)
        .header(
            Header::new().add_paragraph(Paragraph::new().add_run(Run::new().add_text("Header"))),
        );

    Docx::new()
        .add_section(section)
        .add_paragraph(Paragraph::new().add_run(Run::new().add_text("World")))
        .header(Header::new().add_paragraph(Paragraph::new()))
        .build()
        .pack(file)?;
    Ok(())
}