2017-09-06 44 views
0

我正在使用xslt和fo來構建PDF。我的要求是將PDF的內容限制爲只有一頁。將內容適配到PDF中的單個頁面

有些情況下,PDF將分兩頁顯示。我必須避免這種情況。以下是主設置的代碼。

<fo:layout-master-set> 

      <fo:simple-page-master master-name="StandardPage" page-height="250mm" page-width="297mm"> 
       <fo:region-body margin-bottom="20mm" margin-top="12mm" margin-left="14mm" margin-right="6mm"/> 
       <fo:region-before region-name="headerContent" extent="12mm"/> 
       <fo:region-after region-name="footer" extent="20mm" precedence="true"/> 
       <fo:region-start region-name="leftBorder" extent="14mm"/> 
       <fo:region-end region-name="rightBorder" extent="6mm"/> 
      </fo:simple-page-master> 
     </fo:layout-master-set> 
     <fo:page-sequence master-reference="StandardPage"> 
      <fo:flow flow-name="xsl-region-body"> 

下面是xsl中的內容。我們有18個選項,重複18次。

<fo:table-row> 
<fo:table-cell number-columns-spanned="2"> 
    <fo:block font-size="18pt" font-family="ABC" font-weight="bold" text-align="left" line-height="14pt"> 
     <fo:list-block> 
      <fo:list-item> 
       <fo:list-item-label> 
        <fo:block>&#x2022;</fo:block> 
       </fo:list-item-label> 
       <fo:list-item-body start-indent="4mm"> 
        <fo:block> 
        <xsl:variable name="opt18" select="string(//void[@property='optionListEntryEighteen']/string/text())"/> 
         <xsl:value-of select="$opt18"/> 
        </fo:block> 
       </fo:list-item-body> 
      </fo:list-item> 
     </fo:list-block> 
    </fo:block> 
</fo:table-cell> 

有些時候,所有的18個選擇適合單頁和一些次16個選項適合單頁和下兩個選項都被移動到下一個頁面。

我的要求是,以適應在一個單一的頁面的選項(如果10個選項正在被裝在單個頁面則顯示該單頁10,不顯示其他選項。

我怎麼能實現這一

回答

1

我不相信但如何使用FO:單頁主基準& FO:?塊容器@height和@溢出=「隱藏」這是通過FOP測試

[示例FO文件]

<?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="simple-page-master" page-width="10.5in" page-height="5.5in"> 
      <fo:region-body margin-top="0.5in" margin-bottom="0.5in" margin-left="0.5in" 
       margin-right="0.5in"/> 
      <fo:region-before extent="1in" precedence="true" display-align="after"/> 
      <fo:region-start extent="1in"/> 
      <fo:region-end extent="1in"/> 
     </fo:simple-page-master> 
     <fo:page-sequence-master master-name="single-page-master"> 
      <fo:single-page-master-reference master-reference="simple-page-master"/> 
     </fo:page-sequence-master> 
    </fo:layout-master-set> 
    <fo:page-sequence master-reference="single-page-master" reference-orientation="from-page-master-region()" 
     writing-mode="from-page-master-region()" > 
     <fo:flow flow-name="xsl-region-body" font-size="2em"> 
      <fo:block-container height="4in" overflow="hidden" border="thin solid black"> 
       <fo:block>optionListEntry (1)</fo:block> 
       <fo:block>optionListEntry (2)</fo:block> 
       <fo:block>optionListEntry (3)</fo:block> 
       <fo:block>optionListEntry (4)</fo:block> 
       <fo:block>optionListEntry (5)</fo:block> 
       <fo:block>optionListEntry (6)</fo:block> 
       <fo:block>optionListEntry (7)</fo:block> 
       <fo:block>optionListEntry (8)</fo:block> 
       <fo:block>optionListEntry (9)</fo:block> 
       <fo:block>optionListEntry (10)</fo:block> 
       <fo:block>optionListEntry (11)</fo:block> 
       <fo:block>optionListEntry (12)</fo:block> 
       <fo:block>optionListEntry (13)</fo:block> 
       <fo:block>optionListEntry (14)</fo:block> 
       <fo:block>optionListEntry (15)</fo:block> 
       <fo:block>optionListEntry (16)</fo:block> 
       <fo:block>optionListEntry (17)</fo:block> 
       <fo:block>optionListEntry (18)</fo:block> 
      </fo:block-container> 
     </fo:flow> 
    </fo:page-sequence> 
</fo:root> 

[結果]

The result

+0

感謝那些真正幫助:) –

相關問題