Search code examples
pdfxsltxsl-foapache-fop

How to escape " 
" or new line special added character in XSLT PDF?


I'am using apache FOP to convert XML to PDF using XSL 1.0.

I've xml node

<ABC>This is one line&#xD;
  This is second line&#xD;
This is third line</ABC>

and I want Output similar as node i.e

  This is one line 
  This is second line
  This is third line

but it is coming in only one line. so is there any solution to escape "&#xD" in xsl ? Following code is used to get the value of node.

 <xsl:value-of select="ABC" disable-output-escaping="yes"  />

Solution

  • The property you are looking for is linefeed-treatment.

    Setting it to the "preserve" will have the effect of processing a linefeed-separated text as separate paragraphs, so a block like this one

    <fo:block linefeed-treatment="preserve">A
    B
    C</fo:block>
    

    will produce three lines in the output

    A
    B
    C