1
votes

I have an xsl file to generate a pdf. I want to put a footer on the bottom of the last page. I tryed something like this:

<?xml version="1.0" encoding="windows-1252"?>

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html" encoding="windows-1252"/>

<xsl:template match="/">

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:layout-master-set>

            <page-sequence-master master-name="pages">
                <repeatable-page-master-alternatives>
                    <conditional-page-master-reference page-position="last" master-reference="last-page"/>
                    <conditional-page-master-reference master-reference="other-page"/>
                </repeatable-page-master-alternatives>
            </page-sequence-master>

            <fo:simple-page-master master-name="A4" page-width="210mm" page-height="297mm" margin-top="1cm" margin-bottom="1cm"
                                   margin-left="1cm" margin-right="1cm">
                <fo:region-body margin-top="90mm" margin-bottom="80mm"/>
                <fo:region-before extent="90mm"/>
                <fo:region-after extent="80mm"/>
                <fo:region-start/>
                <fo:region-end/>
            </fo:simple-page-master>

        </fo:layout-master-set>
    <html>
        <fo:page-sequence master-reference="A4">
            <fo:static-content flow-name="xsl-region-before">
                <fo:block>
                    header
                </fo:block>
            </fo:static-content>
            <fo:flow flow-name="xsl-region-body">
                body
            </fo:flow>
            <fo:static-content flow-name="xsl-region-after">
                <fo:block>
                    footer
                </fo:block>
            </fo:static-content>
            </fo:page-sequence>

    </html>
    </fo:root>
</xsl:template>

The Footer appears at the end of the body and not at the end of the page, i dont know how to do it.

1
Certainly that xsl with output type html and html tags is not producing the document. Look for consistency in naming. You have a sequence named pages and you page sequence does not use it as it references A4 master.Kevin Brown

1 Answers

0
votes

Your extent value on fo:region-after is the same as the margin-bottom value on the fo:region-body. If you reduce the extent, then the fo:region-after won't extend all the way up to the bottom of the fo:region-body.

See, e.g., the FO and PDF for 'Adding page numbers (page-number)' example at http://www.antennahouse.com/antenna1/comprehensive-xsl-fo-tutorials-and-samples-collection/. The FO includes:

<fo:simple-page-master page-height="150mm" page-width="210mm" margin-top="10mm"
     margin-left="20mm" margin-right="20mm" margin-bottom="10mm" master-name="PageMaster">
  <fo:region-before extent="15mm" />
  <fo:region-after extent="15mm" />
  <fo:region-body margin-top="0mm" margin-left="0mm" margin-right="0mm" margin-bottom="20mm" />
 </fo:simple-page-master>

You can see that here there's a 5mm difference between the extent and the margin-bottom.