You are almost there. Instead of setting this with a TextAlignment object, use a Jc instance (excuse):
PPr paragraphProperties = factory.createPPr(); Jc justification = factory.createJc(); justification.setVal(JcEnumeration.CENTER); paragraphProperties.setJc(justification);
A simple way to figure this out:
- Create the document (and formatting) that you are looking for in Microsoft Word and save the file
- Change the suffix of the .docx file to "zip"
- Open the zip archive, open the word directory and extract the
document.xml file - Learn XML that will give you hints as to which OpenXML objects to use
source share