godocx
godocx copied to clipboard
Paragraph alignment
Hello, loved the library but is there a way to align my paragraph to the center, right or justify the content?
If there's a way I could not find it in the documentation or the examples.
Thanks
Figure out that you can access justification via p.Property.Justification, however p.Property is nil at first, so the best way I was able to make it work was as follows:
p := docx.AddEmptyParagraph()
p.Property = elements.DefaultParaProperty()
p.Property.Justification = elements.NewJustification("both")
I am glad that you find it useful. It needs more work, will try to add more features. Thanks for the raising this issue. It is simplified in > 0.0.8-alpha release https://github.com/gomutex/godocx/releases/tag/v0.0.8-alpha
You can now do
p1 := docx.AddParagraph("Center Justified example")
p1.Justification("center")