XSL FO inline alignment
Solution 1
Elegance wasn't a stated requirement, but this should fit the bill:
<fo:block text-align-last="justify">
LEFT TEXT
<fo:leader leader-pattern="space" />
RIGHT TEXT
</fo:block>
This works by justifying the last line of text in the block, so that the text begins at the left of the line and ends at the right. The leader, which is usually used on Table of Contents pages, stretches to fill the space between the left and right text. Normally it is used as <fo:leader leader-pattern="dots" />
, which produces a stretch of periods, but in this case it merely provides a gulf of space.
Solution 2
This will do the trick:
<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>
Solution 3
<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>
Verified working with FOP 2.0
Related videos on Youtube
Ikke
At young age I already had much interest for computers. It all started with a book about QBasic which got me hooked to programming. Experimented and made lots of little programs for myself. Later on, I started doing more with web development, mainly PHP. Nowadays I'm a professional webdeveloper mainly developping in PHP. In my own time I also do little projects in Python.
Updated on July 09, 2022Comments
-
Ikke almost 2 years
I need to get text aligned right and left on the same line. This should be possible, but i can't seem to find a way. I'm using Apache FOP to convert xml to pdf.
Can someone help me to get this right?
-
Ikke over 15 yearsDoes not work. The two elements are on seperate lines, not on the same line.
-
Martijn Laarman over 15 yearsI've got everything set up at home as well now (needed to anyhow) could you be a bit more specific as to what you want and why fo:table will not work ?
-
Ikke about 15 yearsToo bad, Apache FOP doesn't support fo:float.
-
EthR about 15 yearsalt soft, www.alt-soft.com , the package that I use just added support for it recently. i've not had the chance to try it out yet tho
-
Haroon over 11 yearsworked for me thank you (I added table and columns widths too)
-
MonoThreaded over 11 yearsWorks at table-row level as well. +1
-
Sauer about 7 yearsWow... Finally a neat solution. I ALWAYS build complex one-row-tables for that. Thanks!