Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Put XSL-FO block on next page instead of splitting it across pages

Tags:

xsl-fo

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>   
like image 649
Vojtech Avatar asked Dec 28 '11 12:12

Vojtech


1 Answers

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:

  • http://www.w3.org/TR/xslfo20/#page-break-after
  • http://www.w3.org/TR/xslfo20/#page-break-before
  • http://www.w3.org/TR/xslfo20/#page-break-inside
like image 198
Lukas Eder Avatar answered Jan 04 '23 08:01

Lukas Eder