我正在使用XSL-FO(通过XEP处理器)将XML语料库输出到PDF。我正在使用<fo:marker>
将章节标题放在正在运行的标题中。它工作正常。
但是,我打了一个分页符,以便章节从页面顶部的大号粗体字<chapter-title>
的新页面开始。
因此,我想在每一章的第一页中禁止运行标题。但我无法确定在属性值或其他方面可以做到的方式。
以下是相关代码:
<fo:simple-page-master
master-name="page-recto"
page-height="29.7cm" page-width="21cm"
margin-top="3cm" margin-bottom="2cm"
margin-left="3cm" margin-right="1.5cm">
<fo:region-body
region-name="xsl-region-body"/>
<fo:region-before
region-name="xsl-region-before" extent="12pt" padding="2cm" />
<fo:region-after
region-name="xsl-region-after" extent="12pt" padding-top="2cm"/>
</fo:simple-page-master>
带有master-reference
的{p> fo:marker
用于设置正在运行的标头:
<fo:page-sequence master-reference="page-recto">
<fo:static-content flow-name="xsl-region-before">
<fo:block text-align="center" font-family="Times" font-size="8pt" font-style="normal" margin-bottom="1cm">
<fo:retrieve-marker retrieve-class-name="header-chapter-title"
retrieve-position="first-starting-within-page"
retrieve-boundary="page-sequence"/>
</fo:block></fo:static-content>
<fo:static-content flow-name="xsl-region-after">
<fo:block text-align="center" font-family="Times" font-size="8pt" font-style="normal">
<fo:page-number/>
</fo:block></fo:static-content>
<fo:flow flow-name="xsl-region-body" font-family="Times" font-weight="normal" font-size="10pt" space-before="10pt" space-after="10pt"
end-indent="120pt">
<xsl:apply-templates/>
</fo:flow>
</fo:page-sequence>
chapter
和chapter-title
的模板,page-break-before="always"
触发章节的新页面:
<xsl:template match="chapter">
<fo:block>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="chapter-title">
<fo:block text-align="left" margin-top="2cm" margin-bottom="2cm" font-family="Times" font-size="16pt" page-break-before="always">
<fo:marker marker-class-name="header-chapter-title">
<xsl:value-of select="."/>
</fo:marker>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
以下是XML示例:
<corpus>
<chapter n="1">
<chapter-title>foo chapter title 1</chapter-title>
<deposition>
<deposition-title>foo title 1</deposition-title>
<seg>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean sit amet consectetur mi, et tincidunt lorem. In purus nunc, venenatis vitae purus eu, eleifend elementum metus.</seg>
<seg>Integer ac varius eros. Curabitur vel venenatis odio. Vestibulum sed ultricies est, eget cursus diam.</seg>
</deposition>
<deposition>
<deposition-title>foo title 2</deposition-title>
<seg>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean sit amet consectetur mi, et tincidunt lorem. In purus nunc, venenatis vitae purus eu, eleifend elementum metus.</seg>
<seg>Integer ac varius eros. Curabitur vel venenatis odio. Vestibulum sed ultricies est, eget cursus diam.</seg>
</deposition>
<deposition>
<deposition-title>foo title 3</deposition-title>
<seg>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean sit amet consectetur mi, et tincidunt lorem. In purus nunc, venenatis vitae purus eu, eleifend elementum metus.</seg>
<seg>Integer ac varius eros. Curabitur vel venenatis odio. Vestibulum sed ultricies est, eget cursus diam.</seg>
</deposition>
</chapter>
<chapter n="2">
<chapter-title>foo chapter title 2</chapter-title>
<deposition>
<deposition-title>foo title 1</deposition-title>
<seg>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean sit amet consectetur mi, et tincidunt lorem. In purus nunc, venenatis vitae purus eu, eleifend elementum metus.</seg>
<seg>Integer ac varius eros. Curabitur vel venenatis odio. Vestibulum sed ultricies est, eget cursus diam.</seg>
</deposition>
<deposition>
<deposition-title>foo title 2</deposition-title>
<seg>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean sit amet consectetur mi, et tincidunt lorem. In purus nunc, venenatis vitae purus eu, eleifend elementum metus.</seg>
<seg>Integer ac varius eros. Curabitur vel venenatis odio. Vestibulum sed ultricies est, eget cursus diam.</seg>
</deposition>
<deposition>
<deposition-title>foo title 3</deposition-title>
<seg>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean sit amet consectetur mi, et tincidunt lorem. In purus nunc, venenatis vitae purus eu, eleifend elementum metus.</seg>
<seg>Integer ac varius eros. Curabitur vel venenatis odio. Vestibulum sed ultricies est, eget cursus diam.</seg>
</deposition>
</chapter>
</corpus
提前致谢。
答案 0 :(得分:3)
您可以通过以下方式禁止第一章页面中的正在运行的标题:
fo:simple-page-master
而不是fo:region-before
。fo:page-sequence-master/fo:repeatable-page-master-alternatives
,其中包含对第一页及其余页面的fo:simple-page-master
的引用。fo:page-sequence
。以下是示例fo:layout-master-set
代码:
<fo:layout-master-set>
<fo:simple-page-master
master-name="page-recto-first-page"
page-height="29.7cm" page-width="21cm"
margin-top="3cm" margin-bottom="2cm"
margin-left="3cm" margin-right="1.5cm">
<fo:region-body
region-name="xsl-region-body" margin-bottom="12pt"/>
<fo:region-after
region-name="xsl-region-after" extent="12pt"/>
</fo:simple-page-master>
<fo:simple-page-master
master-name="page-recto"
page-height="29.7cm" page-width="21cm"
margin-top="3cm" margin-bottom="2cm"
margin-left="3cm" margin-right="1.5cm">
<fo:region-body
region-name="xsl-region-body" margin-top="12pt" margin-bottom="12pt"/>
<fo:region-before
region-name="xsl-region-before" extent="12pt" border-bottom="1pt solid blue"/>
<fo:region-after
region-name="xsl-region-after" extent="12pt"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="page-recto-psm">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="page-recto-first-page" page-position="first"/>
<fo:conditional-page-master-reference master-reference="page-recto" page-position="any"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
示例章节页:
示例第二页: