Karthikeyan
Karthikeyan

Reputation: 2001

XSLFO - displaying header and footer

Am converting xml to PDF using XSL FO. I want to display Header contents in the below format

Header Contents

Line 1               Line 1.1
Line 2               Line 1.2
Line 2               Line 1.3

Right now, am trying with the below lines of code :

 <fo:block> Line 1 </fo:block> <fo:block>   Line 1.1 </fo:block>
 <fo:block> Line 2 </fo:block> <fo:block>   Line 1.2 </fo:block>
 <fo:block> Line 3 </fo:block> <fo:block>   Line 1.3 </fo:block>

Upvotes: 0

Views: 645

Answers (2)

Toshihiko Makita
Toshihiko Makita

Reputation: 1304

If you want locate "Line 1" aligned to the left of the header and "Line 1.1" aligned to the right of the header, there is no need to use tabular layout. Below example uses fo:leader object to accomplish this requirement.

    <fo:static-content flow-name="xsl-region-before" font-size="9pt">
        <fo:block space-before="2mm" space-before.conditionality="retain" space-after="2mm"  border-bottom="2pt solid green">
            <fo:block text-align-last="justify">Line 1<fo:leader leader-length.maximum="100%" leader-pattern="space"/>Line 1.1</fo:block>
            <fo:block text-align-last="justify">Line 2<fo:leader leader-length.maximum="100%" leader-pattern="space"/>Line 1.2</fo:block>
            <fo:block text-align-last="justify">Line 3<fo:leader leader-length.maximum="100%" leader-pattern="space"/>Line 1.3</fo:block>
        </fo:block>
    </fo:static-content>

The FOP formatting result: FOP Formatting result

Upvotes: 2

Martin Honnen
Martin Honnen

Reputation: 167571

It looks like a tabular layout then:

        <fo:table width="100%">
            <fo:table-body>
                <fo:table-row>
                    <fo:table-cell>
                        <fo:block> Line 1 </fo:block>
                    </fo:table-cell>
                    <fo:table-cell>
                        <fo:block text-align="right"> Line 1.1 </fo:block>
                    </fo:table-cell>
                </fo:table-row>
                <fo:table-row>
                    <fo:table-cell>
                        <fo:block> Line 2 </fo:block>
                    </fo:table-cell>
                    <fo:table-cell>
                        <fo:block text-align="right"> Line 1.2 </fo:block>
                    </fo:table-cell>
                </fo:table-row>
                <fo:table-row>
                    <fo:table-cell>
                        <fo:block> Line 3 </fo:block>
                    </fo:table-cell>
                    <fo:table-cell>
                        <fo:block text-align="right"> Line 1.3 </fo:block>
                    </fo:table-cell>
                </fo:table-row>
            </fo:table-body>
        </fo:table>

Upvotes: 1

Related Questions