为什么在块进程中溢出?

时间:2016-08-09 09:51:36

标签: xsl-fo apache-fop

我将身高5cm的图片放入block-container高度5cm。我希望图像完全适合,但实际上fop会发出警告:

WARNUNG: Content overflows the viewport of an fo:block-container
in block-progression direction by 5784 millipoints. (See position
19:10)

禁用边框,边距和填充。我应该禁用什么?

<?xml version="1.0"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="bodypage" page-height="29.7cm" page-width="21.0cm" margin="0cm">
<fo:region-body />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="bodypage">
<fo:flow flow-name="xsl-region-body">

    <fo:block-container
      absolute-position = "fixed"
      background-color  = "yellow"
      margin-right      = "5cm"
      top    = "5cm"
      left   = "5cm"
      height = "5cm"
      ><fo:block border="none" padding="0" margin="0"
        ><fo:external-graphic border="none" padding="0" margin="0"
          src="dummy.pdf" width="5cm" height="5cm"
          content-height="scale-to-fit" content-width="scale-to-fit"
        /></fo:block
      ></fo:block-container>

</fo:flow>
</fo:page-sequence>
</fo:root>

顺便说一下,PDF中的图像上方有黄色空间: enter image description here

1 个答案:

答案 0 :(得分:2)

fo:external-graphic是内联级元素。当它包含在一个块中时,在每个已知的内联元素(半前导)之前和之后总会有一些空白区域。

这个空间会导致块容器内容物的高度增加,从而导致溢出。你应该能够指定line-height =&#34; 0pt&#34;在封闭图像的块上,以实现正确的行为。

注意:我没有你要测试的图像,但经常会遇到这种情况,这就是我解决这个问题的方法。