Reputation: 21
How to align some text as center and some text as right align in the same line within a single cell within a table In XSL-FO only.
Upvotes: 2
Views: 3382
Reputation: 8068
Use fo:leader
(see https://www.w3.org/TR/xsl11/#fo_leader).
Using just <fo:leader />
when there is text-align="justify"
on the fo:block
may be sufficient.
If that doesn't give the right result, it may be because the default .optimum value for the leader-length
property (see https://www.w3.org/TR/xsl11/#leader-length) is 12pt. In that case, you probably want something like:
<fo:leader leader-length.optimum="100%" />
If you are using AH Formatter, you can use axf:leader-expansion="force"
(see https://www.antenna.co.jp/AHF/help/en/ahf-ext.html#axf.leader-expansion) to force the leader to expand as much as possible.
Upvotes: 0
Reputation: 3788
If you really need to have both the centered text and the right-aligned text inside the same fo:table-cell
, you could use a negative space between two fo:block
elements to put them apparently on the same line:
<fo:table-cell>
<fo:block text-align="center" space-after="-14.4pt">in the center</fo:block>
<fo:block text-align="right">to the right</fo:block>
</fo:table-cell>
This should work (I tested it with FOP), but it may be considered a bit of a dirty trick; the exact value for space-after
depends on the line height for the first block, which defaults to 1.2 * font-size (itself defaulting to 12pt), so you may have to compute the correct value for your specific situation.
However, I think in many situations you could just
(as Tony Graham already commented, a more precise description of the desired output, or even better an image showing it, would help suggesting the right answer for your situation)
Upvotes: 0
Reputation: 8068
Put each block of text in a separate fo:block
. Use text-align="center"
on the first fo:block
, and use text-align="right"
on the second. See https://www.w3.org/TR/xsl11/#text-align.
Upvotes: 0