Dmitry
Dmitry

Reputation: 13

Print the table to the end of the page in PDF

I have some document with text and tables with various height. The document has table in the end. I need to print this table and continue its borders to the bottom of the page. Is it possible? I use FOP 2.9

<fo:root text-align="center" font-family="Arial" font-size="20pt">
    <fo:layout-master-set>
        <fo:simple-page-master master-name="A4_1" margin="1cm" page-width="21cm" page-height="29.7cm">
            <fo:region-body/>
        </fo:simple-page-master>
    </fo:layout-master-set>
    <fo:page-sequence master-reference="A4_1">
        <fo:flow flow-name="xsl-region-body">
            <fo:table border="1px solid black">
                <fo:table-column/>
                <fo:table-body>
                    <fo:table-row>
                        <fo:table-cell border="1px solid black">
                            <fo:block>123</fo:block>
                            <fo:block>123</fo:block>
                            <fo:block>123</fo:block>
                            <fo:block>123</fo:block>
                            <fo:block>123</fo:block>
                        </fo:table-cell>
                    </fo:table-row>
                </fo:table-body>
            </fo:table>
            <fo:table border="1px solid red" height="100%">
                <fo:table-column/>
                <fo:table-column/>
                <fo:table-body>
                    <fo:table-row height="100%">
                        <fo:table-cell border="1px solid red" block-progression-dimension.optimum="100%">
                            <fo:block>123</fo:block>
                            <fo:block>123</fo:block>
                            <fo:block>123</fo:block>
                            <fo:block>123</fo:block>
                            <fo:block>123</fo:block>
                            <fo:block>123</fo:block>
                        </fo:table-cell>
                        <fo:table-cell border="1px solid red" block-progression-dimension.optimum="100%">
                            <fo:block/>
                        </fo:table-cell>
                    </fo:table-row>
                </fo:table-body>
            </fo:table>
        </fo:flow>
    </fo:page-sequence>
</fo:root>

enter image description here

Upvotes: 0

Views: 35

Answers (2)

Hobbes
Hobbes

Reputation: 2115

The height="100%" attribute fits the table cell to the content. If you replace this with height="20cm" you should get a larger cell. Measure the page to find what height you need.

Upvotes: 0

Tony Graham
Tony Graham

Reputation: 8068

If your final table has a known, fixed height, then you could put the table in an fo:static-content that you direct to the fo:region-after of the last page.

For an example of using page-position="last", see the "Page masters for first, last, and only pages" sample in the XSL-FO samples page at https://www.antennahouse.com/xsl-fo-samples


The next alternative would be to put the table in an fo:footnote with an empty fo:inline so there's no visible footnote marker. (See https://www.w3.org/TR/xsl11/#fo_footnote)

You would need to put the fo:footnote in an fo:block because fo:footnote is only allowed where text and inline FOs are allowed. However, you can probably set the font-size (and line-height) to 0pt so the fo:block does not take up any space. I haven't checked, but you might then need to set your normal font-size on the fo:footnote-body so that the table's text is visible.

You might instead be able to use space-before.optimum="100%" and keep-with-previous.within-page="always" on the last fo:table to get the formatter to maximise the space before the last table, but that might blow up for you and take the last row of the previous table and the last table to a new page to fully maximise the space before the last table.

Another alternative would be to put the last fo:table in an fo:block-container that has block-progression-dimension.optimum="100%", display-align="after", and keep-with-previous.within-page="always", but FOP lists only partial support for display-align, so it, too, might not work.

Upvotes: 0

Related Questions