XSL FO内联对齐

Ikk*_*kke 25 pdf xsl-fo

我需要在同一行上左右对齐文本.这应该是可能的,但我似乎找不到办法.我正在使用Apache FOP将xml转换为pdf.

有人可以帮助我做到这一点吗?

Hil*_*ell 44

优雅不是一个明确的要求,但这应该适合该法案:

<fo:block text-align-last="justify">
  LEFT TEXT
  <fo:leader leader-pattern="space" />
  RIGHT TEXT
</fo:block>
Run Code Online (Sandbox Code Playgroud)

这通过对块中文本的最后一行进行校对来工作,因此文本从行的左侧开始并在右侧结束.通常在目录页面上使用的领导者伸展以填充左右文本之间的空间.通常它被用作<fo:leader leader-pattern="dots" />,产生一段时期,但在这种情况下,它只是提供了一个空间的鸿沟.


Hil*_*ell 12

这样就可以了:

<fo:table>
  <fo:table-column />
  <fo:table-column />

  <fo:table-body>
    <fo:table-row>
      <fo:table-cell>
        <fo:block>LEFT TEXT</fo:block>
      </fo:table-cell>
      <fo:table-cell>
        <fo:block text-align="right">RIGHT TEXT</fo:block>
      </fo:table-cell>
    </fo:table-row>
  </fo:table-body>
</fo:table>
Run Code Online (Sandbox Code Playgroud)


rst*_*mer 5

<fo:inline-container vertical-align="top" inline-progression-dimension="49.9%">
    <fo:block>left content</fo:block>
</fo:inline-container>
<fo:inline-container vertical-align="top" inline-progression-dimension="49.9%">
    <fo:block>right-content</fo:block>
</fo:inline-container>
Run Code Online (Sandbox Code Playgroud)

经验证可使用 FOP 2.0