First of all: i use Apache Formatting Objects Processor 2.3 for generating PDF files
There are two questions that build on each other, so I wanted to put them together in one post.
I have a .fo
file in which i created labeled text blocks where a title is in a left bounded block and the content text in a right bounded block.
First i implemented that with fo:table
elements, but for reasons that are not important here, i need to go with fo:inline-container
instead.
So this is a simplified .fo
file of mine:
<?xml version="1.0" encoding="UTF-8"?>
<fo:root
xmlns="http://www.w3.org/1999/XSL/Format"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="Inhalt-Seiten" page-height="29.7cm" page-width="21cm" margin-top="1.5cm" margin-bottom="1.5cm" margin-left="2cm" margin-right="1.5cm">
<fo:region-body margin-top="3.5cm" margin-bottom="1.25cm" margin-left="1cm" margin-right="1cm"/>
<fo:region-before region-name="MAIN-EVEN-header" extent="3.5cm"/>
<fo:region-after extent="1.25cm"/>
<fo:region-start region-name="MAIN-EVEN-left" extent="1cm"/>
<fo:region-end extent="1cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="Inhalt-Seiten">
<fo:flow flow-name="xsl-region-body">
<fo:block background-color="green">
<fo:inline-container inline-progression-dimension="20%" vertical-align="top" background-color="yellow">
<fo:block>
Test
</fo:block>
</fo:inline-container>
<fo:inline-container inline-progression-dimension="80%" vertical-align="top" background-color="red">
<fo:block>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
</fo:block>
</fo:inline-container>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
That creates the following output:
Solved by using a fo:list-block
instead of fo:inline-container
.
Thanks to @Tony Graham
<fo:block background-color="green">
<fo:list-block provisional-label-separation="0pt" provisional-distance-between-starts="20%">
<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block background-color="yellow">
Test
</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block background-color="red">
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
</fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</fo:block>
Creates the desired output with no margins and perfectly aligned: