Search code examples
scalapdfms-wordxsl-fo

xsl-fo: new line not rendered for word document


I am working on a piece of code(scala) which renders documents like PDF, word etc. using XSL-FO.

At a point in implementation, a new line is introduced using \n. During debugging , I see that resulting xml string is as:

<fo:inline xmlns:fo="http://www.w3.org/1999/XSL/Format">
</fo:inline>

But this is respected only for PDFs, and for word documents no new line is introduced. How to get it working for word too?


Solution

  • White-space characters generally collapse and linefeeds are generally ignored.

    To preserve linefeeds, add either wrap="pre" (see https://www.w3.org/TR/xsl11/#white-space) or linefeed-treatment="preserve" (see https://www.w3.org/TR/xsl11/#linefeed-treatment).

    wrap is a shorthand that sets values for linefeed-treatment, white-space-collapse, white-space-treatment, and wrap-option.


    Your other option is to generate <fo:block />, as @kevin-brown suggested (and as I only just saw).