2012-10-29 38 views
2

我正在使用XSL-FO和XML生成PDF。在文本框中,用户可以输入数据如“1”,然后按ENTER,然后按“2”,ENTER,“3”等。但在PDF中,输出为“1234567”。我如何保留换行符?我已经尝试白空间崩溃,换行处理空白处理但这并没有帮助。换行(进入)即将进入XML。在使用XSL-FO生成的PDF中插入换行符

<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> 

+0

其他注释 < XSL:属性名> 的 user1782348

+0

上面的评论有什么意义? – mzjn

+3

这个问题似乎是一个(不太完整)的这个副本: http://stackoverflow.com/questions/12294398/how-to-insert-line-breaks-in-a-pdf-generated-with-xsl -fo – RobertG

回答

1

它应与下面的XML工作(你应该添加的所有属性):

<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> 

如果XML已经没有换行符,也没有办法你的PDF会。