页面方向取决于条件

Pages orientation depending on condition

我正在尝试根据条件更改我的文档页面方向,但我不知道如何做到这一点。阅读文档没有多大帮助,也找不到任何示例。

我这样设置文档:

<fo:layout-master-set>
        <fo:simple-page-master master-name="first-page" page-height="29.7cm" page-width="21.0cm" margin="1cm 2.1cm 0.8cm 2.1cm">
          <fo:region-body region-name="xsl-region-body" margin-top="105px" margin-bottom="50px"/>
          <fo:region-before region-name="xsl-region-before-first" extent="5in"/>
          <fo:region-after region-name="xsl-region-after" extent="5in" display-align="after"/>
        </fo:simple-page-master>
    <fo:simple-page-master master-name="other-page" page-height="21.0cm" page-width="29.7cm" margin="1cm 2.1cm 0.8cm 2.1cm">
      <fo:region-body region-name="xsl-region-body" margin-top="105px" margin-bottom="50px"/>
      <fo:region-before region-name="xsl-region-before-other" extent="5in"/>
      <fo:region-after region-name="xsl-region-after" extent="5in" display-align="after"/>
    </fo:simple-page-master>
        <fo:page-sequence-master master-name="pages">
      <fo:repeatable-page-master-alternatives>
              <fo:conditional-page-master-reference page-position="first" master-reference="first-page"/>
              <fo:conditional-page-master-reference page-position="only" master-reference="other-page"/>
      </fo:repeatable-page-master-alternatives>
        </fo:page-sequence-master>
  </fo:layout-master-set>


<fo:page-sequence master-reference="pages">
 <fo:static-content flow-name="xsl-region-before-first">
...
 </fo:static-content>
 <fo:static-content flow-name="xsl-region-before-first">
...
 </fo:static-content>
 <fo:static-content flow-name="xsl-region-before-first">
...
 </fo:static-content>
 <fo:flow flow-name="xsl-region-body">
 ...
 </fo:flow>

这是先生成第一个垂直页面,然后其余的都是水平页面。这些水平页面是在 for-each 循环中生成的。我想做的是,在可以位于任何位置的特定 page-before="break" 之后,我可以根据 for-each 项目的数据更改下一页的布局。

编辑:我正在使用 xmlns:fo 版本 2.0 我的确切文档应该如下所示:

    <xsl:for-each select="itemsA">
    ...printed stuff...
    </xsl:for-each>
    <fo:block break-before="page">
    <xsl:for-each select="itemsB">
    ...printed stuff...
    </xsl:for-each>
  1. 制作单独的 fo:page-sequence-master(如果 left/right 页之间没有差异,则制作 fo:simple-page-master,等等)。
  2. 将您的 fo:page-sequence-master 移动到每个 xsl:for-each 中,其中 fo:page-sequence-master 指的是适当的 fo:page-sequence-master(或 `fo:simple-page-master)。

即:

<xsl:for-each select="itemsA">
  <fo:page-sequence master-reference="landscape">
    ...printed stuff...
  </fo:page-sequence>
</xsl:for-each>
<xsl:for-each select="itemsB">
  <fo:page-sequence master-reference="portrait">
    ...printed stuff...
  </fo:page-sequence>
</xsl:for-each>

您不需要 <fo:block break-before="page">,因为 fo:page-sequence 总是生成新的页面序列。