2011-03-31 78 views
4

我正在使用xsl-fo創建帶有編號頁面(x的第x頁)的pdf文檔,但總是在文檔的末尾生成空白頁面。有誰知道爲什麼下面的xsl生成一個空白頁面?如果我刪除fo:block last-page,則空白頁不會呈現。在xsl-fo轉換中防止不需要的空白頁

<xsl:template match="/Report"> 
    <fo:root font-family="Georgia,Garamond,New York,Times,Time New Roman,Serif"> 
     <xsl:copy-of select="$fo-layout-master-set"/> 
     <fo:page-sequence master-reference="default-page" initial-page-number="1" format="1"> 
      <!-- Footer content --> 
      <xsl:call-template name="getStaticFooter"/> 

      <fo:flow><fo:block/> 
      </fo:flow> 
     </fo:page-sequence> 

     <fo:page-sequence master-reference="default-page"> 
      <!-- Footer content --> 
      <xsl:call-template name="getStaticFooter"/> 

      <fo:flow> 

       <fo:block id="last-page"/> 
      </fo:flow> 
     </fo:page-sequence> 
    </fo:root> 
</xsl:template> 

<xsl:template name="getStaticFooter"> 
    <fo:static-content flow-name="xsl-region-after"> 
     <fo:table xsl:use-attribute-sets="contentTable"> 
      <fo:table-column number-columns-repeated="3" width="proportional-column-width(10)"/> 
      <fo:table-body> 
       <fo:table-row> 
        <fo:table-cell text-align="right"> 
         <fo:block> 
          <fo:inline font-size="7pt" font-weight="bold">Generated by </fo:inline> 
         </fo:block> 
         <fo:block> 
          <fo:inline font-size="7pt">Page <fo:page-number/> of <fo:page-number-citation ref-id="last-page"/></fo:inline> 
         </fo:block> 
        </fo:table-cell> 
       </fo:table-row> 
      </fo:table-body> 
     </fo:table> 
    </fo:static-content> 
</xsl:template> 

+0

lwburk,由於用於提高標題。 – tessa 2011-03-31 20:51:28

回答

2

我想這是因爲你有2個不同的fo:page-sequence的。嘗試將<fo:block id="last-page"/>移動到第一頁中的流程末尾,並刪除第二個fo:page-sequence

實施例:

<xsl:template match="/Report"> 
    <fo:root font-family="Georgia,Garamond,New York,Times,Time New Roman,Serif"> 
     <xsl:copy-of select="$fo-layout-master-set"/> 
     <fo:page-sequence master-reference="default-page" initial-page-number="1" format="1"> 
      <!-- Footer content --> 
      <xsl:call-template name="getStaticFooter"/>  
      <fo:flow> 
       <fo:block/><!-- I'm assuming this is where the actual content will exist; there's most likely a <xsl:apply-templates/> here. --> 
       <fo:block id="last-page"/> 
      </fo:flow> 
     </fo:page-sequence>  
    </fo:root> 
</xsl:template> 
+0

你是對的,謝謝! – tessa 2011-03-31 20:49:05

+0

不客氣! – 2011-03-31 22:04:18

相關問題