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

柔情痞子 提交于 2019-12-04 17:37:28

问题


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>   

回答1:


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


来源:https://stackoverflow.com/questions/8655999/put-xsl-fo-block-on-next-page-instead-of-splitting-it-across-pages

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!