XSL:FO 只保留第一页的页眉
XSL:FO Keep the header only for first page
我无法仅在第一页保留 "region-before"。看我的代码:
<fo:layout-master-set>
<fo:simple-page-master master-name="first" margin-right="0.5cm" margin-left="0.5cm" margin-bottom="0.5cm" margin-top="0.75cm" page-width="21cm" page-height="29.7cm">
<fo:region-body region-name="xsl-region-body" margin-top="{$extra-body-margin-top+15.6-$header-margin}cm" margin-bottom="3.5cm" />
<fo:region-before region-name="xsl-region-before" extent="17cm" overflow="hidden" />
<fo:region-after region-name="xsl-region-after" extent="2.8cm" overflow="hidden" />
</fo:simple-page-master>
<fo:page-sequence-master master-name="psmA">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="first" page-position="any" />
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
如果我更改 page-position="first" 并且我的 region-body 超出了第一页,我就会出错。我的想法是只在第一页上保留 region-before,但 region-body 和 region-footer 跟在下一页之后。有没有简单的代码可以玩我的代码?
- 设置没有
fo:region-before
的第二个 fo:simple-page-master
。
- 添加第二个
fo:conditional-page-master-reference
,这样 first
页面母版仅用于第一页(使用 page-position="first"
),其他页面母版用于其余页面(使用page-position="any"
).
这是可行的,因为格式化程序使用第一个替代方案,其所有条件都为真(参见 https://www.w3.org/TR/xsl11/#fo_repeatable-page-master-alternatives)。这也是为什么将带 page-position="any"
的那个放在最后,因为该条件始终为真。
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="first" margin-right="0.5cm" margin-left="0.5cm" margin-bottom="0.5cm" margin-top="0.75cm" page-width="21cm" page-height="29.7cm">
<fo:region-body region-name="xsl-region-body" margin-top="1cm" margin-bottom="3.5cm" />
<fo:region-before region-name="xsl-region-before" extent="17cm" overflow="hidden" />
<fo:region-after region-name="xsl-region-after" extent="2.8cm" overflow="hidden" />
</fo:simple-page-master>
<fo:simple-page-master master-name="rest" margin-right="0.5cm" margin-left="0.5cm" margin-bottom="0.5cm" margin-top="0.75cm" page-width="21cm" page-height="29.7cm">
<fo:region-body region-name="xsl-region-body" margin-top="1cm" margin-bottom="3.5cm" />
</fo:simple-page-master>
<fo:page-sequence-master master-name="psmA">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="first" page-position="first" />
<fo:conditional-page-master-reference master-reference="rest" page-position="any" />
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="psmA">
<fo:static-content flow-name="xsl-region-before">
<fo:block>before</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body" font-size="12pt" line-height="11pt">
<fo:block>content</fo:block>
<fo:block break-before="page">more content</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
我无法仅在第一页保留 "region-before"。看我的代码:
<fo:layout-master-set>
<fo:simple-page-master master-name="first" margin-right="0.5cm" margin-left="0.5cm" margin-bottom="0.5cm" margin-top="0.75cm" page-width="21cm" page-height="29.7cm">
<fo:region-body region-name="xsl-region-body" margin-top="{$extra-body-margin-top+15.6-$header-margin}cm" margin-bottom="3.5cm" />
<fo:region-before region-name="xsl-region-before" extent="17cm" overflow="hidden" />
<fo:region-after region-name="xsl-region-after" extent="2.8cm" overflow="hidden" />
</fo:simple-page-master>
<fo:page-sequence-master master-name="psmA">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="first" page-position="any" />
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
如果我更改 page-position="first" 并且我的 region-body 超出了第一页,我就会出错。我的想法是只在第一页上保留 region-before,但 region-body 和 region-footer 跟在下一页之后。有没有简单的代码可以玩我的代码?
- 设置没有
fo:region-before
的第二个fo:simple-page-master
。 - 添加第二个
fo:conditional-page-master-reference
,这样first
页面母版仅用于第一页(使用page-position="first"
),其他页面母版用于其余页面(使用page-position="any"
).
这是可行的,因为格式化程序使用第一个替代方案,其所有条件都为真(参见 https://www.w3.org/TR/xsl11/#fo_repeatable-page-master-alternatives)。这也是为什么将带 page-position="any"
的那个放在最后,因为该条件始终为真。
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="first" margin-right="0.5cm" margin-left="0.5cm" margin-bottom="0.5cm" margin-top="0.75cm" page-width="21cm" page-height="29.7cm">
<fo:region-body region-name="xsl-region-body" margin-top="1cm" margin-bottom="3.5cm" />
<fo:region-before region-name="xsl-region-before" extent="17cm" overflow="hidden" />
<fo:region-after region-name="xsl-region-after" extent="2.8cm" overflow="hidden" />
</fo:simple-page-master>
<fo:simple-page-master master-name="rest" margin-right="0.5cm" margin-left="0.5cm" margin-bottom="0.5cm" margin-top="0.75cm" page-width="21cm" page-height="29.7cm">
<fo:region-body region-name="xsl-region-body" margin-top="1cm" margin-bottom="3.5cm" />
</fo:simple-page-master>
<fo:page-sequence-master master-name="psmA">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="first" page-position="first" />
<fo:conditional-page-master-reference master-reference="rest" page-position="any" />
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="psmA">
<fo:static-content flow-name="xsl-region-before">
<fo:block>before</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body" font-size="12pt" line-height="11pt">
<fo:block>content</fo:block>
<fo:block break-before="page">more content</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>