0

我正在使用 XSLT-FO 生成一封信 (pdf)。在第一页上,我有公司徽标/图像和信件内容的开头。我不想在任何其他页面上显示徽标,所以我使用可重复页面主替代方案。问题是它在下一页重复文本块 (smf:body),而不是从第一页继续。我做了很多互联网搜索,试图找出原因 - 但我无法解决。这是一个 XSL-FO:

    <xsl:template match="/smf:workItem">                                
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
        <fo:layout-master-set>

            <fo:simple-page-master master-name="first-page" page-height="29.7cm" page-width="21cm" margin-top="0.5cm"  margin-bottom="1cm" margin-left="1.75cm">
                <fo:region-body margin-right="2cm" margin-top="1.27cm" margin-bottom="1mm" /> 
                <fo:region-before region-name="header-first" extent="0mm" />
                <fo:region-after region-name="footer-first" extent="0mm" />
                <fo:region-end border-top-width="5pt" region-name="right-sidebar" writing-mode="tb-rl" extent="10mm" />                 
            </fo:simple-page-master>

            <fo:simple-page-master master-name="all-pages" page-height="29.7cm" page-width="21cm" margin-top="0.5cm"  margin-bottom="1cm" margin-left="1.75cm">
                <fo:region-body margin-left="0.25cm" margin-right="2cm" margin-top="1.27cm" margin-bottom="1mm" /> 
                <fo:region-before region-name="header-normal" extent="0mm" />
                <fo:region-after region-name="footer-normal" extent="0mm" />                    
            </fo:simple-page-master>        


            <fo:page-sequence-master master-name="document" font-family="Helvetica">
                <fo:repeatable-page-master-alternatives>
                    <fo:conditional-page-master-reference page-position="first" master-reference="first-page"/>
                    <fo:conditional-page-master-reference page-position="any" master-reference="all-pages" />
                </fo:repeatable-page-master-alternatives>
            </fo:page-sequence-master>

            <!--
            <fo:page-sequence-master master-name="document" font-family="Helvetica">
                    <fo:single-page-master-reference master-reference="first-page"/>
                    <fo:repeatable-page-master-reference master-reference="all-pages"/>
            </fo:page-sequence-master>
            -->

        </fo:layout-master-set>     

        <fo:page-sequence master-reference="document">          
            <fo:static-content flow-name="header-first" font-size="10pt">                                               
                <fo:external-graphic src="url('C:\Program Files (x86)\numerointeractive\whitemail\Images\club1830.jpg')" />     
            </fo:static-content>                                    

            <fo:flow flow-name="xsl-region-body">                                           
                <fo:block font-size="10pt" linefeed-treatment="preserve" white-space-collapse="false" white-space-treatment="ignore-if-surrounding-linefeed" wrap-option="wrap">    
                    <xsl:value-of select="smf:body"/>                                                           
                </fo:block>                                                     
            </fo:flow>
        </fo:page-sequence>                                                         
    </fo:root>
</xsl:template>

请有人可以帮我解决这个问题。块 (smf:body) 位于定义我的布局的页面序列中,但由于某种原因它重复了它。任何帮助将不胜感激。

谢谢。

ps - 我也尝试过使用单个/可重复的页面母版,但它的行为相同

4

1 回答 1

0

您可以将您的第一页创建为封面,而无需将其包含在 fo:repeatable-page-master-alternatives 元素中。看一个例子:

<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
  <fo:layout-master-set>
    <fo:simple-page-master master-name="Cover" margin="1in" page-height="11in" page-width="8.5in">
      <fo:region-body margin-top="2in"/>
    </fo:simple-page-master>
    <fo:simple-page-master master-name="StoriesOdd" page-height="11in" page-width="8.5in"
      margin=".5in">
      <fo:region-body margin=".5in"/>
      <fo:region-before region-name="oddHead" extent=".5in"/>
      <fo:region-after region-name="oddFoot" extent=".5in"/>
    </fo:simple-page-master>
    <fo:simple-page-master master-name="StoriesEven" page-height="11in" page-width="8.5in"
      margin=".5in">
      <fo:region-body margin=".5in"/>
      <fo:region-before region-name="evenHead" extent=".5in"/>
      <fo:region-after region-name="evenFoot" extent=".5in"/>
    </fo:simple-page-master>
    <fo:page-sequence-master master-name="Stories">
      <fo:repeatable-page-master-alternatives>
        <fo:conditional-page-master-reference master-reference="StoriesOdd" odd-or-even="odd"/>
        <fo:conditional-page-master-reference master-reference="StoriesEven" odd-or-even="even"/>
      </fo:repeatable-page-master-alternatives>
    </fo:page-sequence-master>
    <fo:page-sequence-master master-name="CoverPage">
      <fo:single-page-master-reference master-reference="Cover"/>
    </fo:page-sequence-master>
  </fo:layout-master-set>
  <fo:page-sequence master-reference="CoverPage">
    <fo:flow flow-name="xsl-region-body">
      <fo:block text-align="center" font-weight="bold" font-size="1in"> Cover Page </fo:block>
    </fo:flow>
  </fo:page-sequence>
  <fo:page-sequence master-reference="Stories">
    <fo:static-content flow-name="oddHead">
      <fo:block border-bottom-width="thin" border-bottom-style="solid" border-bottom-color="green"
        font-weight="bold" text-align="outside"> Story Title </fo:block>
    </fo:static-content>
    <fo:static-content flow-name="evenHead">
      <fo:block border-bottom-width="thin" border-bottom-style="solid" border-bottom-color="green"
        font-weight="bold" text-align="outside"> Book of Stories </fo:block>
    </fo:static-content>
    <fo:static-content flow-name="oddFoot">
      <fo:block border-bottom-width="thin" border-bottom-style="solid" border-bottom-color="green"
        font-weight="bold" text-align="outside">
        <fo:page-number/> | </fo:block>
    </fo:static-content>
    <fo:static-content flow-name="evenFoot">
      <fo:block border-bottom-width="thin" border-bottom-style="solid" border-bottom-color="green"
        font-weight="bold" text-align="outside"> | <fo:page-number/>
      </fo:block>
    </fo:static-content>
    <fo:flow flow-name="xsl-region-body">
      <fo:block/>
    </fo:flow>
  </fo:page-sequence>
</fo:root>
于 2013-05-01T10:24:32.453 回答