XSLT - 将元素推送到页面底部

时间:2017-07-04 13:03:55

标签: xslt xsl-fo

我想知道在页面底部推送块元素的方法是什么。我知道<fo:region-after>对象,但我不知道如何将它用于单个页面,因为我想要推送到页面底部的元素只会在一个页面上发生,并且只有在条件得到满足。

我要推的块是:

<fo:block font-size="0" margin-top="10mm" margin-bottom="10mm" margin-left="-10mm">
    <fo:external-graphic width="190mm" content-width="scale-to-fit">
        <xsl:attribute name="src">            
            url('./test.jpg')
        </xsl:attribute>
    </fo:external-graphic>
</fo:block>

页面配置如下所示:

<xsl:template match="/">
    <fo:root xsl:use-attribute-sets="body" xmlns:fo="http://www.w3.org/1999/XSL/Format">
        <fo:layout-master-set>
            <fo:simple-page-master master-name="first"
                page-height="297mm"
                page-width="210mm"
                margin-top="0mm"
                margin-bottom="0mm"
                margin-left="0mm"
                margin-right="0mm">
                <fo:region-body margin-bottom="0" margin-top="0mm" />
                <fo:region-before region-name="header-first" extent="0mm" />
                <fo:region-after region-name="footer-first" extent="20mm" />
            </fo:simple-page-master>
            <fo:simple-page-master master-name="rest"
                page-height="297mm"
                page-width="210mm"
                margin-top="20mm"
                margin-bottom="20mm"
                margin-left="20mm"
                margin-right="20mm">
                <fo:region-body margin-bottom="0" margin-top="0" />
                <fo:region-before region-name="header-rest" extent="0" />
                <fo:region-after region-name="footer-rest" extent="0mm" />
            </fo:simple-page-master>
            <fo:page-sequence-master master-name="document">
                <fo:repeatable-page-master-alternatives>
                    <fo:conditional-page-master-reference
                        page-position="first"
                        master-reference="first" />
                    <fo:conditional-page-master-reference
                        page-position="rest"
                        master-reference="rest" />
                </fo:repeatable-page-master-alternatives>
            </fo:page-sequence-master>
        </fo:layout-master-set>
        <fo:page-sequence id="sequenceID" master-reference="document">
            <fo:static-content flow-name="header-first">
                <fo:block></fo:block>
            </fo:static-content>
            <fo:static-content flow-name="header-rest">
                <xsl:call-template name="header">
                    <xsl:with-param name="attribute-set"></xsl:with-param>
                </xsl:call-template>
            </fo:static-content>
            <fo:static-content flow-name="footer-first">
                <xsl:call-template name="footer-first" />
            </fo:static-content>
            <fo:static-content flow-name="footer-rest">
                <xsl:call-template name="footer-rest" />
            </fo:static-content>
            <fo:flow flow-name="xsl-region-body">                
                <xsl:apply-templates select="//PRINTED_SECTIONS" />
            </fo:flow>
        </fo:page-sequence>
    </fo:root>
</xsl:template>

1 个答案:

答案 0 :(得分:2)

  1. 如果您使用的是AH格式化程序,则可以使用fo:region-body fo:float将图形浮动到axf:float-y="bottom"的底部。请参阅https://www.antennahouse.com/product/ahf64/ahf-float.html
  2. 中的https://www.antennahouse.com/antenna1/comprehensive-xsl-fo-tutorials-and-samples-collection/和“在页面的任意位置排列浮点数(axf:float-reference =”page“)”
  3. 您可以将图片放入fo:footnote。如果默认情况下输出水平线或类似脚注分隔符,则可能还需要生成带fo:static-content的空flow-name="xsl-footnote-separator"以覆盖格式化程序的默认值。请参阅https://www.w3.org/TR/xsl11/#fo_page-sequence以及对'xsl-footnote-separator'的其他参考。