bokuweb / docx-rs

:memo: A .docx file writer with Rust/WebAssembly.
https://bokuweb.github.io/docx-rs/
MIT License
334 stars 57 forks source link

Add firstLineChars indent fearture #668

Open hisphone opened 8 months ago

hisphone commented 8 months ago

I want to set firstLineChars indent. But I found that I can set it, it's not writen to the xml. Can you add this feature to the crate.

impl BuildXML for Indent { fn build(&self) -> Vec { XMLBuilder::new() .indent( self.start, self.special_indent, self.end.unwrap_or_default(), self.start_chars, ) .build() } }

jiker-burce commented 5 months ago

Yes, you can use the special_indent parameter to set the first line indentation. The following snippet demonstrates how to set it up, and it has been verified to produce correct DOCX output:

Paragraph::new().add_run(Run::new().add_text(DUMMY)).indent(
            Some(840), // the left margin of the paragraph 
            Some(SpecialIndentType::FirstLine(720)), // Used to set the first line indentation, hanging indentation
            None,
            None,
        )

Environment: MacOs Version: Sonoma 14.3.1 docx-rs version: 0.4.8

hisphone commented 2 months ago

Thanks for your help