2012-08-06 27 views
3

我正在實施FOP使用XSLTXML文件,我希望保留單詞之間的空格。
這是我XML看起來像:使用FOP保留生成PDF中的空格

<lines> 
     <line1>  My Creation  </line1> 
     <line2>         address one AAAAAAAAAAA</line2> 
     <line3>   This is the    address of creation</line3> 
    <lines> 

以下是在PDF形式的結果:

My Creation 
    address one AAAAAAAAAAA 
    This is address of creation 

但我需要它是這樣的:

   My Creation  
              address one AAAAAAAAAAA 
        This is the    address of creation 

因此保留所有空間。 我用下面一行:

<xsl:preserve-space elements="*"/> 

,但無濟於事。
我搜索解決方案但徒勞無功。
任何幫助,將不勝感激。

+0

[XSL轉換後,保留空白的PDF]的可能重複(http://stackoverflow.com/questions/10320622/preserving-whitespace-in-pdf-after-xsl-transform) – 2012-08-07 05:54:43

回答

5
<fo:block font-family="monospace" white-space="pre" text-align="left"> 
    <xsl:value-of select="." /> 
</fo:block> 
  1. white-space="pre"將保留空格
  2. font-family="monospace"將關於 尺寸到人物的均衡空間