Page 1 of 1

Remove leading and trailing spaces from document.xml

PostPosted: Wed May 06, 2020 11:58 pm
by ashanaik
Hi

For the WORD document generated using docx4j library , the document.xml content has leading and trailing spaces.
Its formatted.

Is there any way to NOT format the xml.

XML :
Code: Select all
    <w:body><!-- Created by docx4j 11.1.3 (Apache licensed) using REFERENCE JAXB in AdoptOpenJDK Java 11.0.6 on Windows 10 -->
        <w:p>
            <w:pPr>
                <w:rPr>
                    <w:sz w:val="16"/>
                </w:rPr>
            </w:pPr>
            <w:r>
                <w:t xml:space="preserve"></w:t>
            </w:r>
            <w:r>
                <w:rPr>
                    <w:noProof w:val="true"/>
                </w:rPr>
                <mc:AlternateContent>
                    <mc:Choice Requires="wps">
                        <w:drawing>

Re: Remove leading and trailing spaces from document.xml

PostPosted: Fri May 08, 2020 6:52 am
by jason
Set property docx4j.jaxb.formatted.output=false

See further https://github.com/plutext/docx4j/blob/ ... rties#L156

Interested to understand why you don't want it pretty printed?