每隔第n页打印一些东西

时间:2017-11-06 10:01:43

标签: xslt xsl-fo apache-fop

我正在制作一个文件,该文件将自动包裹在信封中。

为此目的,文档需要每5页及其最后一页上标记一个标记。

问题是AFAIK,XSL不能依赖< fo:page>由FO提供。

有人能想到解决方案吗?

1 个答案:

答案 0 :(得分:2)

我能做的最好的事情也要求你在fo:page-sequence-master中放足够的重复次数来处理最大页数。

为了制作更小的屏幕截图,此示例在每个第三页和最后一页上添加标记:

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
    xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions"
    font-size="36pt">
    <fo:layout-master-set>
        <fo:simple-page-master master-name="spm" page-width="5in" page-height="5in">
            <fo:region-body margin="36pt"/>
        </fo:simple-page-master>
        <fo:simple-page-master master-name="marked" page-width="5in" page-height="5in">
            <fo:region-body margin="36pt"/>
            <fo:region-start extent="36pt"/>
        </fo:simple-page-master>
        <fo:page-sequence-master master-name="psm">
            <fo:repeatable-page-master-alternatives maximum-repeats="2">
                <fo:conditional-page-master-reference master-reference="marked" page-position="last"/>
                <fo:conditional-page-master-reference master-reference="spm"/>
            </fo:repeatable-page-master-alternatives>
            <fo:single-page-master-reference master-reference="marked"/>
            <fo:repeatable-page-master-alternatives maximum-repeats="2">
                <fo:conditional-page-master-reference master-reference="marked" page-position="last"/>
                <fo:conditional-page-master-reference master-reference="spm"/>
            </fo:repeatable-page-master-alternatives>
            <fo:single-page-master-reference master-reference="marked"/>
            <!-- Repeat as often as necessary. -->
            <fo:repeatable-page-master-alternatives maximum-repeats="2">
                <fo:conditional-page-master-reference master-reference="marked" page-position="last"/>
                <fo:conditional-page-master-reference master-reference="spm"/>
            </fo:repeatable-page-master-alternatives>
            <fo:single-page-master-reference master-reference="marked"/>
        </fo:page-sequence-master>
    </fo:layout-master-set>
    <fo:page-sequence master-reference="psm">
        <fo:static-content flow-name="xsl-region-start">
            <fo:block margin-top="2in"><fo:external-graphic width="100%" src="logo-antenna.svg" content-width="scale-down-to-fit"/></fo:block>
        </fo:static-content>
        <fo:flow flow-name="xsl-region-body">
            <fo:block break-after="page">1</fo:block>
            <fo:block break-after="page">2</fo:block>
            <fo:block break-after="page">3</fo:block>
            <fo:block break-after="page">4</fo:block>
            <fo:block>5</fo:block>
        </fo:flow>
    </fo:page-sequence>
</fo:root>

enter image description here