代码之家  ›  专栏  ›  技术社区  ›  GingerHead

使用FOP在生成的PDF中保留空白

  •  3
  • GingerHead  · 技术社区  · 14 年前

    我正在实施 FOP 使用 XSLT XML 文件中我想保留单词之间的空白。
    这就是我 XML语言 看起来像:

       <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="*"/>
    

    但无济于事。
    我在谷歌上搜索解决方案,但徒劳无功。
    如有任何帮助,我们将不胜感激。

    1 回复  |  直到 14 年前
        1
  •  5
  •   GingerHead    14 年前
    <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" 将使空间大小相等 与角色的