14

I created an XSL-FO template which prints a few blocks containing texts that change dynamically. Sometimes a block is split across two pages because there is not enough space on the page. Is there a way to put the block on the next page instead of splitting it across pages if it does not fit? I tried to put it into a table with keep-together="always" but then each text is on single line (no line wrapping) and overflows the right page margin where it disappears. Thank you in advance!

  <fo:table table-layout="fixed" width="100%">
    <fo:table-column column-width="proportional-column-width(1)"/>
    <fo:table-body>
      <fo:table-row keep-together="always">
        <fo:table-cell
          border-width="1px"
          border-color="black"
          border-style="solid"
          background-color="#ffffff"
          text-align="left">
          <fo:block>
            Text 1
          </fo:block>
          <fo:block>
            Text 2
          </fo:block>
          <fo:block>
            Text 3
          </fo:block>
        </fo:table-cell>
      </fo:table-row>
    </fo:table-body>        
  </fo:table>   
Adam Arold
  • 29,285
  • 22
  • 112
  • 207
Vojtech
  • 2,533
  • 9
  • 34
  • 65
  • 1
    possible duplicate of [How do you add a page break in a PDF with XSL-FO?](http://stackoverflow.com/questions/225654/how-do-you-add-a-page-break-in-a-pdf-with-xsl-fo) – Lukas Eder Dec 28 '11 at 13:12

1 Answers1

19

Most likely, you could use the page-break-inside attribute:

<fo:block page-break-inside="avoid">
  ...
</fo:block>

There also exist other page-break attributes. Take the best one:

Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509