2

I am generating a PDF using XSL-FO and XML. In a textbox, the user can enter data like "1", then he presses ENTER, then "2", ENTER, "3", etc. But in PDF, the output is "1234567". How can I preserve the line breaks? I already tried white-space-collapse, linefeed-treatment, and white-space-treatment but that didn't help. Line feed (enters) are coming in XML although.

<xsl:template match="AddCmt">
<fo:block keep-together="always"> Additional Comments 
    <fo:block-container border-style="solid" height="20mm" width="170mm" space-after="5mm"> 
        <fo:block wrap-option="wrap" linefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="preserve"> 
            <xsl:attribute name="id"> 
                <xsl:value-of select="../CMT_ID"/> 
            </xsl:attribute> 
            <xsl:value-of select="../ANS_CMT"/> 
        </fo:block> 
    </fo:block-container> 
</fo:block> 

Matej
  • 6,004
  • 2
  • 28
  • 27
  • Additional Comments – user1782348 Oct 29 '12 at 08:45
  • What is the point of the comment above? – mzjn Oct 30 '12 at 06:43
  • 3
    This question seems to be a (less complete) duplicate of this one: http://stackoverflow.com/questions/12294398/how-to-insert-line-breaks-in-a-pdf-generated-with-xsl-fo – RobertG Dec 05 '12 at 19:41
  • Possible duplicate of [Inserting a line break in a PDF generated from XSL FO using ](http://stackoverflow.com/questions/3661483/inserting-a-line-break-in-a-pdf-generated-from-xsl-fo-using-xslvalue-of) – Daniel Haley Jun 29 '16 at 20:34

1 Answers1

1

It should work with the following xml (you should add all the attributes):

<xsl:template match="AddCmt">
    <fo:block keep-together="always"> Additional Comments 
        <fo:block-container border-style="solid" height="20mm" width="170mm" space-after="5mm"> 
            <fo:block wrap-option="wrap" linefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="preserve"> 
                <xsl:attribute name="id"> 
                    <xsl:value-of select="../CMT_ID"/> 
                </xsl:attribute> 
                <xsl:value-of select="../ANS_CMT"/> 
            </fo:block> 
        </fo:block-container> 
    </fo:block> 
</xsl:template> 

If your XML already has no linebreaks, there's no way your PDF will.

NealGul
  • 101
  • 1
  • 3
  • 13