Page 1 of 1

Export-Fo preserve whitespaces

PostPosted: Mon Jan 14, 2019 7:49 pm
by adams
Hi Jason,

when generating .fo files I noticed that the whitespace preserve function is not working.

Code: Select all
         
         // Handle empty case - want the block to be preserved!
         if (n.getChildNodes().getLength()==0) {
            
            ((Element)foBlockElement).setAttribute( "white-space-treatment", "preserve");
            foBlockElement.setTextContent(" ");
            
         } else {
            /*
             * ...
             */
            XmlUtils.treeCopy( n,  foBlockElement );
            
         }


I think it should be:

Code: Select all
         
         // Handle empty case - want the block to be preserved!
         if (n.getChildNodes().getLength()==0) {
            
            ((Element)foBlockElement).setAttribute( "white-space-treatment", "preserve");
            foBlockElement.setTextContent(" ");
            
         } else {
            /*
             * ...
             */
            ((Element)foBlockElement).setAttribute( "white-space-treatment", "preserve");
            ((Element)foBlockElement).setAttribute( "white-space-collapse", "false");
            XmlUtils.treeCopy( n,  foBlockElement );
            
         }


docx4j-export-FO/src/main/java/org/docx4j/convert/out/fo/XsltFOFunctions.java file ~610 line

Re: Export-Fo preserve whitespaces

PostPosted: Sat Jan 26, 2019 11:03 am
by jason
Sorry for the delay with this; please try https://docx4java.org/docx4j/docx4j-exp ... 190126.jar

https://github.com/plutext/docx4j-expor ... eac74bd996 is your suggested change plus some refactoring.