1
votes

I am trying to print table at the bottom of the page(A4 format), but instead of that, last table keeps printing after previous element, despite the fact of margin-bottom property. Additionaly, if I am trying to set footer (using fo:footnote with fo:inline) - this footer also appearing not in the bottom of the page, but under last element.

    <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:template match="/">
        <fo:root>
            <fo:layout-master-set >
                <fo:simple-page-master master-name="simple" page-height="29.7cm" page-width="21cm"
                                       margin-top="2cm" margin-bottom="2cm" margin-left="2cm" margin-right="2cm">
                    <fo:region-body />
                    <!--<fo:region-after region-name="first-page-footer" margin-bottom="2cm" extent="11in" display-align="after"/>-->
                </fo:simple-page-master>
            </fo:layout-master-set>
            <fo:page-sequence master-reference="simple">
                <xsl:call-template name="mainTemplate"/>
            </fo:page-sequence>
        </fo:root>
    </xsl:template>

    <xsl:template name="mainTemplate">

        <xsl:variable name="newline">
            <xsl:text>&#160;</xsl:text>
        </xsl:variable>
        <xsl:variable name="logoURL" >
            <xsl:value-of select="/export/logotype"/>
        </xsl:variable>
        <xsl:variable name="signatureURL">
            <xsl:value-of select="/export/signature"/>
        </xsl:variable>

        <fo:flow flow-name="xsl-region-body">
            <fo:block space-before="2cm" space-after="2cm" font-size="12pt"
                      font-family="Times New Roman">

                <fo:block  space-before="2cm" space-after="2cm" >
                    <fo:table  border-color="black" border-style="solid"
                          border-width="0.5pt"  >
                        <fo:table-column column-width="3cm" border-color="black" border-style="solid"
                                     border-width="0.5pt"/>
                        <fo:table-column column-width="3cm" border-color="black" border-style="solid"
                                     border-width="0.5pt"/>
                        <fo:table-column column-width="3cm" border-color="black" border-style="solid"
                                     border-width="0.5pt"/>
                        <fo:table-column column-width="8cm" border-color="black" border-style="solid"
                                     border-width="0.5pt"/>
                        <fo:table-body>
                            <fo:table-row>
                                <fo:table-cell border-color="black" border-style="solid" border-width="0.5pt">
                                    <fo:block font-weight="bold" text-align="center">Number</fo:block>
                                </fo:table-cell>
                                <fo:table-cell border-color="black" border-style="solid" border-width="0.5pt">
                                    <fo:block font-weight="bold" text-align="center">Date</fo:block>
                                </fo:table-cell>
                                <fo:table-cell border-color="black" border-style="solid" border-width="0.5pt">
                                    <fo:block font-weight="bold" text-align="center">Bill</fo:block>
                                </fo:table-cell>
                                <fo:table-cell border-color="black" border-style="solid" border-width="0.5pt">
                                    <fo:block font-weight="bold" text-align="center">Owner</fo:block>
                                </fo:table-cell>
                            </fo:table-row>

                            <xsl:for-each select="/export/Cars/car">
                                <xsl:variable name="param1" select="number"/>
                                <xsl:variable name="param2" select="date"/>
                                <xsl:variable name="param3" select="bill"/>
                                <xsl:variable name="param4" select="owner"/>
                                <fo:table-row>
                                    <fo:table-cell border-color="black" border-style="solid" border-width="0.5pt"
                                               padding-left="3pt">
                                        <fo:block text-align="center">
                                            <xsl:value-of select="$param1"/>
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border-color="black" border-style="solid" border-width="0.5pt"
                                               padding-left="3pt" padding-right="3pt" display-align="center">
                                        <fo:block text-align="center">
                                            <xsl:value-of select="$param2"/>
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell border-color="black" border-style="solid" border-width="0.5pt"
                                               padding-left="3pt" padding-right="3pt" display-align="center">
                                        <fo:block text-align="center">
                                            <xsl:value-of select="$param3"/>
                                        </fo:block>
                                    </fo:table-cell >
                                    <fo:table-cell border-color="black" border-style="solid" border-width="0.5pt"
                                               padding-left="3pt" padding-right="3pt" display-align="center">
                                        <fo:block text-align="center">
                                            <xsl:value-of select="$param4"/>
                                        </fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                            </xsl:for-each>
                        </fo:table-body>
                    </fo:table>
                </fo:block>

                <fo:block>
                    <xsl:value-of select="$newline"/>
                </fo:block>
                <fo:block>
                    <xsl:value-of select="$newline"/>
                </fo:block>

                <fo:block space-after="2cm" >
                    <fo:table  border-color="black" border-style="solid"
                               border-width="0.5pt"  >
                        <fo:table-column column-width="3cm" border-color="black" border-style="solid" border-width="0.5pt"/>
                        <fo:table-column column-width="14cm" border-color="black" border-style="solid" border-width="0.5pt"/>
                        <fo:table-body>
                            <fo:table-row>
                                <fo:table-cell border-color="black" border-style="solid" border-width="0.5pt">
                                    <fo:block font-weight="bold" text-align="center">Graph 6</fo:block>
                                </fo:table-cell>

                                <fo:table-cell border-color="black" border-style="solid" border-width="0.5pt">
                                    <fo:block  text-align="center"><xsl:value-of select="/export/graph6"/></fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                            <fo:table-row>
                                <fo:table-cell border-color="black" border-style="solid" border-width="0.5pt">
                                    <fo:block font-weight="bold" text-align="center">Graph 5</fo:block>
                                </fo:table-cell>

                                <fo:table-cell border-color="black" border-style="solid" border-width="0.5pt">
                                    <fo:block  text-align="center"><xsl:value-of select="/export/graph5"/></fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                            <fo:table-row>
                                <fo:table-cell border-color="black" border-style="solid" border-width="0.5pt">
                                    <fo:block font-weight="bold" text-align="center">Graph 4</fo:block>
                                </fo:table-cell>

                                <fo:table-cell border-color="black" border-style="solid" border-width="0.5pt">
                                    <fo:block  text-align="center"><xsl:value-of select="/export/graph4"/></fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                            <fo:table-row>
                                <fo:table-cell border-color="black" border-style="solid" border-width="0.5pt">
                                    <fo:block font-weight="bold" text-align="center">Graph1</fo:block>
                                </fo:table-cell>

                                <fo:table-cell border-color="black" border-style="solid" border-width="0.5pt">
                                    <fo:block  text-align="center"><xsl:value-of select="/export/graph1"/></fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                            <fo:table-row>
                                <fo:table-cell border-color="black" border-style="solid" border-width="0.5pt">
                                    <fo:block font-weight="bold" text-align="center">Graph 2</fo:block>
                                </fo:table-cell>

                                <fo:table-cell border-color="black" border-style="solid" border-width="0.5pt">
                                    <fo:block  text-align="center"><xsl:value-of select="/export/graph2"/></fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                            <fo:table-row>
                                <fo:table-cell border-color="black" border-style="solid" border-width="0.5pt">
                                    <fo:block font-weight="bold" text-align="center">Graph3</fo:block>
                                </fo:table-cell>

                                <fo:table-cell border-color="black" border-style="solid" border-width="0.5pt">
                                    <fo:block  text-align="center"><xsl:value-of select="/export/graph3"/></fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                        </fo:table-body>
                    </fo:table>
                </fo:block>

                <fo:block>
                    <xsl:value-of select="$newline"/>
                </fo:block>
                <fo:block>
                    <xsl:value-of select="$newline"/>
                </fo:block>

                <fo:block text-align="justify" >
                    <xsl:value-of select="/export/contactInfo"/>
                </fo:block>

                <fo:block>
                    <xsl:value-of select="$newline"/>
                </fo:block>

                <fo:table  border-width="0" margin-bottom="3cm" >
                    <fo:table-column column-width="5.6cm" />
                    <fo:table-column column-width="5.6cm" />
                    <fo:table-column column-width="5.6cm" />
                    <fo:table-body>
                        <fo:table-row>
                            <fo:table-cell display-align="after">
                                <fo:block text-align="left">
                                    Occupation <xsl:value-of select="/export/occupation"/>
                                </fo:block>
                            </fo:table-cell>
                            <fo:table-cell display-align="before">
                                <fo:block text-align="center">
                                    Signature <fo:external-graphic src='url({$signatureURL})'/>
                                </fo:block>
                            </fo:table-cell>
                            <fo:table-cell display-align="after">
                                <fo:block text-align="left">
                                    Name <xsl:value-of select="/export/name"/>
                                </fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                    </fo:table-body>
                </fo:table>

            </fo:block>

        </fo:flow>
    </xsl:template>

</xsl:stylesheet>

Output file in .doc format
Code on pastebin
The problem with footnotes is - when I am trying to put content into a footnote(fo:block statement placed instead of last fo:table from previous code section ):

...
<fo:block>
            The quick brown fox jumps over a lazy dog. The quick brown fox jumps over
            a lazy dog. The quick brown fox jumps over a lazy dog.
        <fo:footnote>
            <fo:inline baseline-shift="super"  font-size="10pt">
                (*)
            </fo:inline>
            <fo:footnote-body>
                <fo:block>
                    * This is the first footnote
                </fo:block>
            </fo:footnote-body>
        </fo:footnote>
            The quick brown fox jumps over a lazy dog. The quick brown fox jumps over
            a lazy dog.
 </fo:block>
</fo:flow>
</xsl:template>
</xsl:stylesheet>

output result looks like this:

...
The quick brown fox jumps over a lazy dog. The quick brown fox jumps over a lazy dog. The quick brown fox jumps over a lazy dog. (*) The quick brown fox jumps over a lazy dog. The quick brown fox jumps over a lazy dog.
* This is the first footnote

The footnote string placed immediatly after previous text, not at the bottom of the page

2
include XML file so that others can give solution.Hash
Output file is .doc format. Added links to output file and xsl code after first block of codeMark Jopa

2 Answers

3
votes

The margin-bottom property indicates that you want a space below the table. It has nothing to do with placing an object at the bottom of a page. If you want the table to appear at the bottom of the page, there are 2 options:

  1. insert it in the region-after area, not in the body area.
  2. Wrap it in a block-container which has an absolute position.
1
votes

I put content I want at the bottom of the page into a footnote construct in an empty block with an empty inline citation. Let the formatter worry about where the bottom of the page is. I tell my students this is an appropriate approach for things like legal disclaimers at the bottom of the last page of a document.

The problem with an absolutely-positioned block-container is that if its dimensions overlap with the body, then it is possible for body content to overwrite it. If the body content is shrunk for that content, you need to accommodate the different areas in the page geometries.

I find it easiest just to throw it into a footnote.