How can I create a footer on the last page

别说谁变了你拦得住时间么 提交于 2021-01-29 06:42:53

问题


Here the clean code:

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <fo:layout-master-set>
        <fo:simple-page-master
                master-name="pages-normale"
                page-width="297mm"
                page-height="210mm"
                margin-top="0.5cm"
                margin-bottom="0.5cm"
                margin-left="0.5cm"
                margin-right="0.5cm">
            <fo:region-body   margin-top="1cm" margin-bottom="1cm"/>
            <fo:region-before margin-top="1cm" margin-bottom="1cm" extent="7cm"/>
            <fo:region-after  margin-top="1cm" margin-bottom="1cm" extent="1cm"/>
        </fo:simple-page-master>
    </fo:layout-master-set>
    <fo:page-sequence
            master-reference="pages-normale"
            initial-page-number="1"
            force-page-count="even"
            language="it"
            country="it">
        <fo:static-content flow-name="xsl-region-before">
            <fo:block>
                <fo:table  width="100%" border-width="0.5mm" margin-bottom="4mm" border-style="transparent">
                    <fo:table-column  column-width="50%"/>
                    <fo:table-column  column-width="50%"/>
                    <fo:table-header>
                        <fo:table-row>
                            <fo:table-cell border-style="normal">
                                <fo:block font-size="15" font-style="oblique" font-weight="bold">

                                </fo:block>
                            </fo:table-cell>
                            <fo:table-cell border-style="normal">
                                <fo:block font-size="8" font-weight="normal" text-align="right"/>
                            </fo:table-cell>
                        </fo:table-row>
                    </fo:table-header>
                    <fo:table-body>
                        <fo:table-row>
                            <fo:table-cell border-style="transparent">
                                <fo:block>
                                    <fo:block font-size="8" text-align="left" font-weight="normal" >
                                    </fo:block>
                                </fo:block>
                            </fo:table-cell>
                            <fo:table-cell border-style="transparent">
                                <fo:block>
                                    <fo:block font-size="8" text-align="left" font-weight="normal" >
                                    </fo:block>
                                </fo:block>
                            </fo:table-cell>
                        </fo:table-row>             
                    </fo:table-body>
                </fo:table>
            </fo:block>
        </fo:static-content>
        <fo:static-content flow-name="xsl-region-after">
            <fo:block>
                <xsl:value-of select="intestazione2_1/cliente3"/>
            </fo:block>
        </fo:static-content>
        <fo:flow flow-name="xsl-region-body">
            <fo:block>

            </fo:block>
            <fo:block>

            </fo:block>
        </fo:flow>
    </fo:page-sequence>
</fo:root>

Here the code that I've tried:

I made this on layout master-set:

<fo:layout-master-set>
    <fo:simple-page-master
                master-name="pages-normale"
                page-width="297mm"
                page-height="210mm"
                margin-top="0.5cm"
                margin-bottom="0.5cm"
                margin-left="0.5cm"
                margin-right="0.5cm">
        <fo:region-body   margin-top="1cm" margin-bottom="1cm"/>
        <fo:region-before region-name="normal-header" margin-top="1cm" margin-bottom="1cm" extent="7cm"/>
        <fo:region-after  region-name="normal-footer" margin-top="1cm" margin-bottom="1cm" extent="1cm"/>
    </fo:simple-page-master>
    <fo:page-sequence-master master-name="pages">
        <fo:repeatable-page-master-alternatives>
            <fo:conditional-page-master-reference master-reference="pages-last" page-position="last"/>
            <fo:conditional-page-master-reference master-reference="pages-normale" />
        </fo:repeatable-page-master-alternatives>
    </fo:page-sequence-master>
</fo:layout-master-set>

And go this on the following code:

 <fo:page-sequence
        master-reference="pages-normale"

Do this in the page sequence:

<fo:page-sequence force-page-count="no-force"
                    master-reference="pages" initial-page-number="auto"
                    format="1">
    <fo:static-content flow-name="normal-footer">
        <xsl:value-of select="intestazione2_1/cliente3"/>
    </fo:static-content>
</fo:page-sequence>

I've tried to put this page sequence in and out of the <fo:page-sequence master-reference="pages-normale" But the error is the same.

Here the error that FOP gives me:

No simple-page-master matching "pages-last" in page-sequence-master "fo:repeatable-page-master-alternatives". (No context info available)

Here the advice that I followed:

  • How to detect the last page of the document?
  • XSL-FO footer on last page

回答1:


In addition to your <fo:simple-page-master master-name="pages-normale"> you need to define <fo:simple-page-master master-name="pages-last">.

In this master, you need to define a footer with a unique name for the last page <fo:region-after region-name="last-page-footer". Then in your page-sequence, you can add <fo:static-content flow-name="last-page-footer"> and add the information you want to display in that footer.



来源:https://stackoverflow.com/questions/56775607/how-can-i-create-a-footer-on-the-last-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!