XSL keep-together and page-break-inside not working

2.6k views Asked by At

I've tried the following suggestions and none have worked, my <fo:block> keeps getting split between the two inner blocks.

<fo:block keep-with-next="always" page-break-inside="avoid">
  <fo:block keep-together="always">
    Block # 1, a header
  </fo:block>

  <fo:block keep-together="always">
    Block # 2, a bunch of text
  </fo:block>
</fo:block>

How can I keep the two inner blocks together on the page? I am using FO.NET, in case that has limitations.

1

There are 1 answers

0
Kevin Brown On

I think you should contact FO.NET folks. Testing this example with RenderX XEP and with Apache FOP yields 3 pages output. At 10.36in the whole text of your block fits on the page, at 10.37in it does not. In both products, all of the content in your block is moved to the following page. Note that the only required tag is the page-break-inside="avoid", nothing else.

        <fo:flow flow-name="xsl-region-body">
            <fo:block>Space</fo:block>
            <fo:block space-before="10.36in">I Generate One Page</fo:block>
            <fo:block page-break-inside="avoid">
                <fo:block >
                    Block # 1, a header
                </fo:block>
                <fo:block>
                    Block # 2, a bunch of text
                </fo:block>
            </fo:block>
            <fo:block break-before="page">I Generate Two Pages</fo:block>
            <fo:block space-before="10.37in">Space</fo:block>
            <fo:block page-break-inside="avoid">
                <fo:block >
                    Block # 1, a header
                </fo:block>
                <fo:block>
                    Block # 2, a bunch of text
                </fo:block>
            </fo:block>
        </fo:flow>

In looking at the FO.NET website, it has not been updated since 2009. I don;t see anything about their (lack of) support for keeps but coming from another XSL FO vendor, keeps are pretty difficult to do correctly in code.