0

I have a business requirement where I am rendering table data in a PDF. The requirement is that the contents of the table must not exceed one page including header/footer. Each row of the table can vary in height so it's not as simple as just limiting the number of rows to output. How it works now is that the table contents spill over to as many pages as are needed to render the table.

Does anyone know how I can limit the output of a table to just one page? BTW, I pretty new to xsl and xsl-fo.

Thank you much!

4

1 回答 1

1

没有明确说明你想要什么,如果你只是想切断溢出,你有几种方法。由于它只有一页,我根本不会费心做页眉/页脚区域。我会将所有内容放在您希望大小的绝对定位的块容器中。

对于“中间”,将表格放在块容器内并在其上设置溢出 =“隐藏”。

我使用 RenderX XEP 和 Apache FOP 对此进行了测试,非常适合消除溢出。

像这样:

<fo:page-sequence master-reference="first">
    <fo:flow flow-name="xsl-region-body">
        <fo:block-container position="absolute" top="3in" left="1in" height="1in" width="7in" overflow="hidden" border="1pt solid black">
            <fo:block>
                <fo:table border="solid 1pt blue">
                    <fo:table-column column-number="1" column-width="1.25in"/>
                    <fo:table-column column-number="2" column-width="3in"/>
                    <fo:table-body>
                        <fo:table-row border="solid 1pt red">
                            <fo:table-cell >
                                <fo:block>1.25in</fo:block>
                            </fo:table-cell>
                            <fo:table-cell>
                                <fo:block>3in</fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row>
                            <fo:table-cell>
                                <fo:block>1.25in</fo:block>
                            </fo:table-cell>
                            <fo:table-cell>
                                <fo:block>3in</fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row>
                            <fo:table-cell>
                                <fo:block>1.25in</fo:block>
                            </fo:table-cell>
                            <fo:table-cell>
                                <fo:block>3in</fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row>
                            <fo:table-cell>
                                <fo:block>1.25in</fo:block>
                            </fo:table-cell>
                            <fo:table-cell>
                                <fo:block>3in</fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row>
                            <fo:table-cell>
                                <fo:block>1.25in</fo:block>
                            </fo:table-cell>
                            <fo:table-cell>
                                <fo:block>3in</fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row>
                            <fo:table-cell>
                                <fo:block>1.25in</fo:block>
                            </fo:table-cell>
                            <fo:table-cell>
                                <fo:block>3in</fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row>
                            <fo:table-cell>
                                <fo:block>1.25in</fo:block>
                            </fo:table-cell>
                            <fo:table-cell>
                                <fo:block>3in</fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row>
                            <fo:table-cell>
                                <fo:block>1.25in</fo:block>
                            </fo:table-cell>
                            <fo:table-cell>
                                <fo:block>3in</fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row>
                            <fo:table-cell>
                                <fo:block>1.25in</fo:block>
                            </fo:table-cell>
                            <fo:table-cell>
                                <fo:block>3in</fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                    </fo:table-body>
                </fo:table>
            </fo:block>

        </fo:block-container>
    </fo:flow>
</fo:page-sequence>
于 2013-08-24T17:28:18.957 回答