1
0
mirror of https://github.com/fumiama/go-docx.git synced 2026-06-05 07:40:24 +08:00
Files
go-docx/apipara.go
2023-02-23 14:34:44 +08:00

30 lines
810 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package docxlib
// AddParagraph adds a new paragraph
func (f *Docx) AddParagraph() *Paragraph {
f.Document.Body.mu.Lock()
defer f.Document.Body.mu.Unlock()
f.Document.Body.Paragraphs = append(f.Document.Body.Paragraphs, Paragraph{
Children: make([]interface{}, 0, 64),
file: f,
})
return &f.Document.Body.Paragraphs[len(f.Document.Body.Paragraphs)-1]
}
// Justification allows to set para's horizonal alignment
//
// w:jc 属性的取值可以是以下之一:
// start左对齐。
// center居中对齐。
// end右对齐。
// both两端对齐。
// distribute分散对齐。
func (p *Paragraph) Justification(val string) *Paragraph {
if p.Properties == nil {
p.Properties = &ParagraphProperties{}
}
p.Properties.Justification = &Justification{Val: val}
return p
}