2012-10-29 41 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會。