简体   繁体   English

XSL-FO:如何添加可变页母版引用

[英]XSL-FO: How to add variable page master references

I am working on a duplex document which needs a front page (with an image eg. 'Letterhead.jpg'), a backer for that page (with a backer image eg' Backer.jpg'), and if information for that front page flows over the page boundaries, it flows into a 'continuation' page (with image 'continuation'). 我正在处理一个双面文档,该文档需要一个首页(带有图像,例如“ Letterhead.jpg”),该页面的支持者(带有衬底图像,例如“ Backer.jpg”),以及该首页的信息在页面边界上流动,然后流入“连续”页面(图像为“连续”)。 This continuation page also requires the same 'continuation.jpg' image on the back, with information then flowing onto that reverse page. 该连续页面的背面也需要相同的“ continuation.jpg”图像,然后信息流到该反向页面上。

I am having issues with setting this up correctly. 我在正确设置此设置时遇到问题。 I currently have my primary page working fine, but from there its not formatting as i'd wish. 我目前的主页工作正常,但从那里开始我所希望的格式却没有。 If the primary page has no overflow, then the reverse is pulling the continuation graphic by default. 如果主页没有溢出,则默认情况下反之则是拉起连续图形。 And then when there is an overflow, the data flows onto the backer (with continuation graphic), and then any subsequent pages. 然后,当发生溢出时,数据将流到支持者(带有连续图形)上,然后流到任何后续页面上。

Im sorry if this post confuses, and im not explaining very well, im summary, what I need is: 我很抱歉,如果这篇文章令人困惑,并且我不能很好地解释我的摘要,我需要的是:

Primary Page : flow data with letterhead.jpg graphic. 主页面 :具有letterhead.jpg图形的流数据。

Reverse of primary page : no data to flow onto here. 反转主页面 :此处没有数据流。 only backer.jpg graphic. backer.jpg图形。 (if flow data from Primary page overflows page boundaries then..) (如果“主页面”中的流数据溢出了页面边界,那么..)

Continuation Page : continuation of flow data from primary, with continuation.jpg graphic. Continuation Page :继续从主要流数据,具有continuation.jpg图形。

Reverse of Continuation Page: continuation of flow data from Continuation Page, with continuation.jpg graphic. 连续页面反转:连续页面中流数据的延续,带有continuation.jpg图形。

End Page : A blank page to go at the end. 末页末尾的空白页。

Here is my current code: 这是我当前的代码:

 <fo:layout-master-set>
    <fo:page-sequence-master master-name="document">
        <fo:repeatable-page-master-alternatives>
              <fo:conditional-page-master-reference master-reference="continuation-even" page-position="first" odd-or-even="even"/>
              <fo:conditional-page-master-reference master-reference="letter" page-position="first"/>
              <fo:conditional-page-master-reference master-reference="continuation-odd" odd-or-even="odd"/>
              <fo:conditional-page-master-reference master-reference="continuation-rest" odd-or-even="even"/>
              <fo:conditional-page-master-reference master-reference="last" page-position="last" odd-or-even="even"/>
        </fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>      
<fo:simple-page-master master-name="letter" page-height="32.0cm" page-width="22.5cm" margin-top="1.15cm" margin-bottom="2.15cm" margin-left="0.75cm" margin-right="0.75cm">
    <fo:region-body margin-top="10.3cm" margin-bottom="2cm" margin-left="1.6cm" margin-right="2.5cm" />
        <fo:region-before region-name="letterhead graphic" extent="29.7cm"/>
                    </fo:simple-page-master>
                    <fo:simple-page-master master-name="continuation-odd" page-height="32.0cm" page-width="22.5cm" >
                        <fo:region-body margin-top="4.5cm" margin-bottom="1.8cm" margin-left="2.3cm" margin-right="2.0cm" />
                        <fo:region-before region-name="continuation graphic" extent="29.7cm"/>
                    </fo:simple-page-master>
                    <fo:simple-page-master master-name="continuation-even" page-height="32.0cm" page-width="22.5cm" >
                        <fo:region-body margin-top="32.0cm" margin-bottom="0cm" margin-left="2.5cm" margin-right="2.0cm" />
                            <fo:region-before region-name="backer" extent="29.7cm"/>
                    </fo:simple-page-master>
                    <fo:simple-page-master master-name="continuation-rest" page-height="32.0cm" page-width="22.5cm" >
                        <fo:region-body margin-top="4.5cm" margin-bottom="1.8cm" margin-left="2.3cm" margin-right="2.0cm" />
                        <fo:region-before region-name="continuation graphic" extent="29.7cm"/>
                    </fo:simple-page-master>
                    <fo:simple-page-master master-name="last" page-height="32.0cm" page-width="22.5cm" >
                        <fo:region-body margin-top="0.5cm" margin-bottom="0.5cm" margin-left="0.5cm" margin-right="2.0cm" />
                        <fo:region-before region-name="end-page" extent="29.7cm"/>
                    </fo:simple-page-master>
                    <fo:simple-page-master master-name="separator" page-height="32.0cm" page-width="22.5cm" margin-top="2.15cm" margin-bottom="1.15cm" margin-left="1.75cm" margin-right="0.75cm">
            <fo:region-body/>
    </fo:simple-page-master>
</fo:layout-master-set>

THATS IT! 而已!

going through what you mentioned and what you added your original question solved the problem. 仔细阅读您提到的内容和您添加的原始问题,即可解决问题。

Here is the code we have now put together which does exactly what we need. 这是我们现在放在一起的代码,完全可以满足我们的需求。

<xsl:template match="/">
    <fo:root>
        <fo:layout-master-set>
            <fo:page-sequence-master master-name="document">
                <fo:repeatable-page-master-alternatives maximum-repeats="2">
                    <fo:conditional-page-master-reference master-reference="front" odd-or-even="odd"/>
                    <fo:conditional-page-master-reference master-reference="back-special" odd-or-even="even"/>
                </fo:repeatable-page-master-alternatives>
                <fo:repeatable-page-master-alternatives>
                    <fo:conditional-page-master-reference master-reference="front" odd-or-even="odd"/>
                    <fo:conditional-page-master-reference master-reference="back" odd-or-even="even"/>
                </fo:repeatable-page-master-alternatives>
            </fo:page-sequence-master>
            <fo:simple-page-master master-name="front" page-height="29.7cm" page-width="21.0cm" margin-top="5cm" margin-bottom="5cm" margin-left="2.5cm" margin-right="2.5cm">
                <fo:region-body/>
            </fo:simple-page-master>
            <fo:simple-page-master master-name="back" page-height="29.7cm" page-width="21.0cm" margin-top="5cm" margin-bottom="5cm" margin-left="2.5cm" margin-right="2.5cm">
                <fo:region-body/>
            </fo:simple-page-master>
            <fo:simple-page-master master-name="back-special" page-height="29.7cm" page-width="21.0cm" margin-top="5cm" margin-bottom="25cm" margin-left="2.5cm" margin-right="2.5cm">
                <fo:region-body/>
                <fo:region-before region-name="special" extent="29.7cm"/>
            </fo:simple-page-master>
        </fo:layout-master-set> 

        <fo:page-sequence master-reference="document">
            <fo:static-content flow-name="special">
                <fo:block>
                    <fo:external-graphic src="url('special.jpg')"/>
                </fo:block>
            </fo:static-content>

            <fo:flow flow-name="xsl-region-body" font-family="Helvetica" font-size="14pt">
                <fo:block>
                    <xsl:for-each select="/data/item">
                        <fo:block space-after="2cm"><xsl:value-of select="."/></fo:block>
                    </xsl:for-each>
                </fo:block>
            </fo:flow>
        </fo:page-sequence>
    </fo:root>
</xsl:template>

Thanks for your help! 谢谢你的帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM