Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

External-graphic has space above even though I've set it to zero

Tags:

xml

xsl-fo

My XSL-FO template has an image in the footer of each page:

<fo:block-container left="0mm" top="10mm" absolute-position="absolute" width="210mm" height="10mm" border="0.1pt black solid" margin="0mm" padding="0mm" space-before="0mm">
    <fo:block border="0.1pt green solid" margin="0mm" padding="0mm" space-before="0mm">
        <fo:external-graphic src="grayblock.pdf"  height="10mm" content-height="scale-to-fit" border="0.1pt blue solid" margin="0mm" padding="0mm" space-before="0mm"/>
    </fo:block>
</fo:block-container>

I expect the top of the image to be aligned with the top of the block-container. But this is the result I get:

enter image description here

My image (the blue/gray rectangle) starts about 0.5 mm below the top of the block-container (the distance between the black line and the blue/gray rectangle).

What I've tried:

  • I inserted margin="0mm" padding="0mm" space-before="0mm" to make sure the block-container, block and external-graphic don't inherit any margins, padding etc. from ancestors. That didn't change the result.
  • Adding a negative margin/padding doesn't move the external-graphic up.
  • setting the borders to "none" doesn't resolve the problem. I've added the borders to visualize which of the elements is causing the problem.

Normally, this 0.5 mm gap doesn't matter much. In this case, I'm trying to align two block-containers and their contents, and the difference is making it difficult to get them to line up exactly.

How do I eliminate this gap above the external-graphic?

(I'm using Antenna House XSL Formatter 6.1)

like image 715
Hobbes Avatar asked Oct 20 '25 15:10

Hobbes


1 Answers

I think the gap has two culprits:

  • the three borders (on fo:block-container, fo:block and fo:external-graphic), which erode the available heigth
  • the half-leading trait

Removing the borders and setting the block line-height to be exactly 10mm should avoid the gap (I tested with FOP 2.2):

<fo:block-container left="0mm" top="30mm" absolute-position="absolute" width="210mm" height="10mm" margin="0mm" padding="0mm" space-before="0mm" background-color="#AAFFFF">
    <fo:block line-height="10mm" line-stacking-strategy="font-height" margin="0mm" padding="0mm" space-before="0mm" background-color="#FFFFAA">
        <fo:external-graphic vertical-align="top" src="grayblock.pdf" height="10mm" content-height="scale-to-fit" margin="0mm" padding="0mm" space-before="0mm"/>
    </fo:block>
</fo:block-container>
like image 187
lfurini Avatar answered Oct 23 '25 08:10

lfurini



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!