Search code examples
xsl-foapache-fop

Why overflow in block-progression?


I put an image of height 5cm into a block-container of height 5cm. I expect that the image should fit perfectly, but actually fop gives a warning:

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

The border, margins and padding are disabled. What else should I disable?

<?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>

By the way, the image in PDF has yellowspace above: enter image description here


Solution

  • An fo:external-graphic is an inline-level element. When it is contained in a block, there is always a bit of white space before and after each inline element known (half-leading).

    It's this space that leads to increased height of the block-container content and thus to the overflow. You should be able to specify line-height="0pt" on the block that encloses the image in order to achieve correct behavior.

    NOTE: I did not have you image to test but frequently encounter this and that is how I solve this issue.