当表格跨越多个页面时,如何在每个页面上重复使用XSL-FO表格标题?

时间:2012-12-17 20:57:50

标签: xsl-fo

我有一些非常长的表,它们跨越多个页面,使用Apache-FOP 1.1进行渲染

表格有一个标题,例如“表7.6。某事物的详细信息”和列标题。

在每个续页上,列标题在顶部正确重复。但我还需要表格延续部分也有标题,形式如下:“表7.6。某事的细节(续)”

有没有办法用XSL-FO和Apache-FOP做到这一点?或者它是否需要通过RenderX提供扩展?

1 个答案:

答案 0 :(得分:6)

我不知道在FOP中做到这一点的方法,但这可能是因为我没有将FOP用于基本PDF生成以外的其他任何内容。

使用RenderX(XEP),您可以将fo:table-header设置为您想要在续页上使用的任何标题,并使用常规fo:block作为初始标题。

然后,您可以使用rx:table-omit-initial-header="true"上的fo:table属性在第一次输出表时不输出表头。

以下是RenderX 4.18 ...

呈现的示例

示例XSL-FO

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" 
    xmlns:rx="http://www.renderx.com/XSL/Extensions">
    <fo:layout-master-set>
        <fo:simple-page-master master-name="my-page" page-width="8.5in" page-height="11in">
            <fo:region-body margin="1in" margin-top="1.5in" margin-bottom="1.5in"/>
        </fo:simple-page-master>
    </fo:layout-master-set>
    <fo:page-sequence master-reference="my-page">
        <fo:flow flow-name="xsl-region-body">
            <fo:block font-size="12pt" font-weight="bold" 
                text-align="center" space-after="6pt">Sample Table</fo:block>
            <fo:block>
                <fo:table rx:table-omit-initial-header="true" space-before=".08in">
                    <fo:table-column column-width="100%"/>
                    <fo:table-header>
                        <fo:table-cell>
                            <fo:block font-weight="bold"
                                font-size="12pt" text-align="center" 
                                space-after="6pt">Sample Table (Cont)</fo:block>
                        </fo:table-cell>
                    </fo:table-header>
                    <fo:table-body>
                        <fo:table-row>
                            <fo:table-cell>
                                <fo:table border-style="solid" border-width="1pt" padding="6pt">
                                    <fo:table-column column-number="1" column-width="20%"/>
                                    <fo:table-column column-number="2" column-width="80%"/>
                                    <fo:table-header font-weight="bold">
                                        <fo:table-cell text-align="left">
                                            <fo:block>Column 1</fo:block>
                                        </fo:table-cell>
                                        <fo:table-cell>
                                            <fo:block>Column 2</fo:block>
                                        </fo:table-cell>
                                    </fo:table-header>
                                    <fo:table-body>
                                        <fo:table-row padding-before="20px">
                                            <fo:table-cell>
                                                <fo:block>Lorem ipsum dolor sit amet</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn’t commit. These men promptly escaped from a
                                                    maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune.</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block>Lorem ipsum dolor sit amet</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn’t commit. These men promptly escaped from a
                                                    maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune.</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block>Lorem ipsum dolor sit amet</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn’t commit. These men promptly escaped from a
                                                    maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune.</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block>Lorem ipsum dolor sit amet</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn’t commit. These men promptly escaped from a
                                                    maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune.</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block>Lorem ipsum dolor sit amet</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn’t commit. These men promptly escaped from a
                                                    maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune.</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block>Lorem ipsum dolor sit amet</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn’t commit. These men promptly escaped from a
                                                    maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune.</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block>Lorem ipsum dolor sit amet</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn’t commit. These men promptly escaped from a
                                                    maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune.</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block>Lorem ipsum dolor sit amet</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn’t commit. These men promptly escaped from a
                                                    maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune.</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block>Lorem ipsum dolor sit amet</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn’t commit. These men promptly escaped from a
                                                    maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune.</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block>Lorem ipsum dolor sit amet</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn’t commit. These men promptly escaped from a
                                                    maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune.</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block>Lorem ipsum dolor sit amet</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn’t commit. These men promptly escaped from a
                                                    maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune.</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block>Lorem ipsum dolor sit amet</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn’t commit. These men promptly escaped from a
                                                    maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune.</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block>Lorem ipsum dolor sit amet</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn’t commit. These men promptly escaped from a
                                                    maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune.</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block>Lorem ipsum dolor sit amet</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn’t commit. These men promptly escaped from a
                                                    maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune.</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block>Lorem ipsum dolor sit amet</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn’t commit. These men promptly escaped from a
                                                    maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune.</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block>Lorem ipsum dolor sit amet</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn’t commit. These men promptly escaped from a
                                                    maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune.</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block>Lorem ipsum dolor sit amet</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn’t commit. These men promptly escaped from a
                                                    maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune.</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block>Lorem ipsum dolor sit amet</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn’t commit. These men promptly escaped from a
                                                    maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune.</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block>Lorem ipsum dolor sit amet</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn’t commit. These men promptly escaped from a
                                                    maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune.</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block>Lorem ipsum dolor sit amet</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn’t commit. These men promptly escaped from a
                                                    maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune.</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block>Lorem ipsum dolor sit amet</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn’t commit. These men promptly escaped from a
                                                    maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune.</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                            <fo:table-cell>
                                                <fo:block>Lorem ipsum dolor sit amet</fo:block>
                                            </fo:table-cell>
                                            <fo:table-cell>
                                                <fo:block>Ten years ago a crack commando unit was sent to prison by a military court for a crime they didn’t commit. These men promptly escaped from a
                                                    maximum security stockade to the Los Angeles underground. Today, still wanted by the government, they survive as soldiers of fortune.</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                    </fo:table-body>
                                </fo:table>
                            </fo:table-cell>
                        </fo:table-row>
                    </fo:table-body>
                </fo:table>
            </fo:block>
        </fo:flow>
    </fo:page-sequence>
</fo:root>

示例PDF输出第1页

enter image description here

示例PDF输出第2页

enter image description here