我正在使用xslt和fo来构建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>•</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个选项,而不显示其他选项。
我怎样才能做到这一点?
答案 0 :(得分:1)
我不自信但是如何使用fo:single-page-master-reference&amp; fo:带@height和@ overflow =“hidden”的块容器?这是通过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>
[结果]