xsl-fo:两个平行的报告,一个在奇数页,另一个在偶数页 [英] xsl-fo: Two reports en parallel, one in odd pages another in even pages
问题描述
我想生成一个 PDF,其中一个内容流在奇数页,另一个在偶数页,所以当你双面打印 PDF 时,你有一个模板来写笔记偶数页.这是我所拥有的,但它不起作用:
I want to generate a PDF having one content flow in odd pages and another in even pages, so when you print the PDF double sided you have a template to write notes even pages. This is what I have but it does not work:
<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<!-- Odd Pages -->
<fo:simple-page-master master-name="odd" page-height="297mm" page-width="210mm" margin-left="2mm" margin-right="2mm">
<fo:region-body region-name="body-odd" margin-top="118mm" margin-bottom="50mm"/>
<fo:region-before region-name="headerodd" extent="116mm"/>
<fo:region-after region-name="footerodd" extent="48mm"/>
</fo:simple-page-master>
<!-- Even Pages -->
<fo:simple-page-master master-name="even" page-height="297mm" page-width="210mm" margin-left="2mm" margin-right="2mm">
<fo:region-body region-name="body-even" margin-top="118mm" margin-bottom="50mm"/>
<fo:region-before region-name="headereven" extent="116mm"/>
<fo:region-after region-name="footereven" extent="48mm"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="A4">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference master-reference="odd" blank-or-not-blank="any" odd-or-even="odd"/>
<fo:conditional-page-master-reference master-reference="even" blank-or-not-blank="any" odd-or-even="even"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A4">
<fo:flow flow-name="body-odd">
<fo:block page-break-after="always">
This is an ODD page. Front-page report 1.
</fo:block>
<fo:block page-break-after="always">
This is an ODD page. Front-page report 1.
</fo:block>
<fo:block page-break-after="always">
This is an ODD page. Front-page report 1.
</fo:block>
</fo:flow>
</fo:page-sequence>
<fo:page-sequence master-reference="A4">
<fo:flow flow-name="body-even">
<fo:block page-break-after="always">
This is an EVEN page. Back-page report 2
</fo:block>
<fo:block page-break-after="always">
This is an EVEN page. Back-page report 2
</fo:block>
<fo:block page-break-after="always">
This is an EVEN page. Back-page report 2
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
推荐答案
将笔记页面的静态内容放在指向 fo:region 的
(或任何其他外部区域)偶数页:fo:static-content
中-before
Put the static content for the notes pages in an fo:static-content
that is directed to the fo:region-before
(or any of the other outer regions) of the even page:
<fo:page-sequence master-reference="A4">
<fo:static-content flow-name="headereven">
<fo:block>
This is an EVEN page. Back-page report 2
</fo:block>
</fo:static-content>
<fo:flow flow-name="body-odd">
<fo:block page-break-after="always">
This is an ODD page. Front-page report 1.
</fo:block>
<fo:block page-break-after="always">
This is an ODD page. Front-page report 1.
</fo:block>
<fo:block page-break-after="always">
This is an ODD page. Front-page report 1.
</fo:block>
</fo:flow>
</fo:page-sequence>
这样,您就不需要拥有与您的真实内容相匹配的准确页数.
This way, you don't need to have exactly the right number of pages worth of note content to match your real content.
您可以定位内容,使其显示在页面上的正确位置.如果您将静态内容定向到 fo:region-before
,则不必担心使用正确的范围,因为任何溢出该区域的内容在默认情况下都将保持可见.
You can position the content so that it shows up at the correct position on the page. If you direct the static content to fo:region-before
, you shouldn't have to worry about using the correct extent since any content that overflows the region will remain visible by default.
这篇关于xsl-fo:两个平行的报告,一个在奇数页,另一个在偶数页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!