我有一个需要不同页面布局的文档。 例如:
目前,我只使用一个页面顺序母版,其中我可以为首页以及偶数和奇数页使用不同的简单页面母版。但是我需要从输出PDF的开头,主要部分和结尾进行不同的处理。
在我的XML中,我有类似的东西:
<!-- should be rendered to page layout "A" -->
<section>
<layout>beginning</layout>
...
</section>
<!-- should be rendered to page layout "B" -->
<section>
<layout>mainpart</layout>
...
</section>
<!-- should be rendered to page layout "C" -->
<section>
<layout>end</layout>
...
</section>
这些部分包含许多数据,例如章节段落,图片... 所以最终它变成了大约45页的PDF
我的XSL看起来像这样:
<xsl:template match="/">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="DIN-A4-ODD" page-height="29.7cm" page-width="21cm" margin-top="1.5cm" margin-bottom="1.5cm" margin-left="2cm" margin-right="1.5cm">
<fo:region-body margin-top="3.5cm" margin-bottom="1.5cm" margin-left="1cm" margin- right="1cm" />
<fo:region-before region-name="ODD-header" extent="3.5cm" />
<fo:region-after region-name="ODD-footer" extent="1.5cm" />
<fo:region-start region-name="ODD-left" extent="1cm" />
<fo:region-end region-name="ODD-right" extent="1cm" />
</fo:simple-page-master>
<fo:simple-page-master master-name="DIN-A4-EVEN" page-height="29.7cm" page-width="21cm" margin-top="1.5cm"
margin-bottom="1.5cm" margin-left="2cm" margin-right="1.5cm">
<fo:region-body margin-top="3.5cm" margin-bottom="1.5cm" margin-left="1cm"
margin-right="1cm" />
<fo:region-before region-name="EVEN-header" extent="3.5cm" />
<fo:region-after region-name="EVEN-footer" extent="1.5cm" />
<fo:region-start region-name="EVEN-left" extent="1cm" />
<fo:region-end region-name="EVEN-right" extent="1cm" />
</fo:simple-page-master>
<fo:simple-page-master master-name="TITLEPAGE" page-height="29.7cm" page-width="21cm" margin-top="1cm"
margin-bottom="1cm" margin-left="1cm" margin-right="1cm">
<fo:region-body />
<fo:region-after region-name="TITLEPAGE-footer" extent="1cm" />
</fo:simple-page-master>
<fo:page-sequence-master master-name="DIN-A4">
<fo:single-page-master-reference master-reference="TITLEPAGE"
page-position="first"/>
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="DIN-A4-ODD"
odd-or-even="odd" page-position="any" />
<fo:conditional-page-master-reference master-reference="DIN-A4-EVEN"
odd-or-even="even" page-position="any" />
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="DIN-A4">
<!-- TITLEPAGE-footer logo -->
<fo:static-content flow-name="TITLEPAGE-footer">
<fo:block text-align="right">
<fo:external-graphic src="url(file:C:Logo.pdf)" max-height="1cm" />
</fo:block>
</fo:static-content>
<!-- ODD Header Content -->
<fo:static-content flow-name="ODD-header">
<fo:block text-align="right" font-size="8pt">
<fo:inline>
<fo:retrieve-marker retrieve-class-name="HeadingSection" />
</fo:inline>
<fo:inline>
<fo:retrieve-marker retrieve-class-name="HeadingChapter" />
</fo:inline>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="ODD-right">
<fo:block text-align="right" font-size="8pt">
<fo:inline>
<fo:page-number />
</fo:inline>
</fo:block>
</fo:static-content>
<!-- EVEN Header Content -->
<fo:static-content flow-name="EVEN-header">
<fo:block text-align="left" font-size="8pt">
<fo:inline>
<fo:retrieve-marker retrieve-class-name="HeadingSection" />
</fo:inline>
<fo:inline>
<fo:retrieve-marker retrieve-class-name="HeadingChapter" />
</fo:inline>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="EVEN-left">
<fo:block text-align="left" font-size="8pt">
<fo:inline>
<fo:page-number />
</fo:inline>
</fo:block>
</fo:static-content>
<!-- body declaration -->
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates />
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
正如我所说,我不知道如何获得所需的动力,我希望有人能帮助我解决这个问题。
答案 0 :(得分:1)
您使用不同的名称创建多个fo:page-sequence-master。您的示例中有一个...根据需要创建多个。例如:
<fo:page-sequence-master master-name="DIN-A4-A"> ... definition here for your "A" pages
<fo:page-sequence-master master-name="DIN-A4-B"> ... definition here for your "B" pages
<fo:page-sequence-master master-name="DIN-A4-C"> ... definition here for your "C" pages
<fo:page-sequence-master master-name="DIN-A4-D"> ... definition here for your "D" pages
然后,您通过引用您已定义的主序列的页面序列在内容中输出它们。
<fo:page-sequence master-reference="DIN-A4-A"> ... stuff here for your "A" pages
<fo:page-sequence master-reference="DIN-A4-B"> ... stuff here for your "B" pages
<fo:page-sequence master-reference="DIN-A4-C"> ... stuff here for your "C" pages
<fo:page-sequence master-reference="DIN-A4-D"> ... stuff here for your "D" pages
在页面顺序定义中,如果某些页面是共享/相同的,则您可以引用不同甚至相同的简单页面母版。表示一组页面的每个“块”内容都是您的页面序列,它指的是页面序列母版(或者,如果不是序列,则实际上可以指的是简单页面母版)。