I'm trying to inline the text test
between images, but as soon as I add text, I get spacing at the top and bottom of the text.
As I've discovered earlier, in order to get rid of those top and bottom spacing that's breaking the image layout, I need to set the font-size to 0:
But font-size zero is pretty useless if you want to display text.
<fo:block font-size="0" >
<fo:external-graphic src=" http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_13.jpg"/>
</fo:block>
<fo:block background-color="pink" font-size="0pt" >
<fo:external-graphic src="http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_14.jpg"/>
test
<fo:external-graphic src="http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_16.jpg"/>
</fo:block>
<fo:block background-color="magenta" font-size="0" >
<fo:external-graphic src=" http://www.mycee.com/image/20135-Test-Mockup-V1.0-01_17.jpg"/>
</fo:block>
Putting the text inside fo-inline
, I can at least get rid of the top padding, but there's still padding at the bottom breaking my layout.
<fo:inline font-size="10pt">
test
</fo:inline>
What is the correct way to insert text between images without the text causing padding to appear at the top or bottom?
Update
Finally got it working
<fo:block background-color="pink" line-height="2.4mm" line-stacking-strategy="none" font-size="11pt">
<fo:table>
<fo:table-column/>
<fo:table-column/>
<fo:table-column/>
<fo:table-body>
<fo:table-row>
<fo:table-cell text-align="left">
<fo:block>
<fo:external-graphic
src="http://www.mycee.com/images/20135-Test-Mockup-V1.0-01_14.jpg"/>
</fo:block>
</fo:table-cell>
<fo:table-cell text-align="right">
<fo:block>
12345678.90
</fo:block>
</fo:table-cell>
<fo:table-cell text-align="right">
<fo:block>
<fo:external-graphic
src="http://www.mycee.com/images/20135-Test-Mockup-V1.0-01_16.jpg"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
If you zoom enough, you'll eventually see a line, but for printing purposes, this is perfect.
The "padding" you see could be due to the way line height is computed.
Line height is controlled by two different FO properties:
line-height
sets the starting value, the one deriving from the block's text content; its default value is normal
, and FOP calculates it as 1.2 * font-size
line-stacking-strategy
controls how the starting value is modified if the fo:block
contains inline elements (fo:inline
s, images, ...) besides simple text; it defaults to max-height
, meaning (roughly speaking) that the line height is increased to fit images and inlines having larger font sizeNow, let us look at your specific situation:
font-size
defaults to 12pt, which means that the initial value for line height is 1.2 * 12pt = 14.4pt; if the height of your images is less than that, they will appear having some space at the top and at the bottomfont-size="0pt"
kinda works, because the initial line height would be 0pt, which would be subsequently increased to the height of the images Suggested change:
line-height="x" line-stacking-strategy="font-height"
(where x
is the height of your images) in the fo:block
elements containing text and images; the combined effect of these properties is to set the line height to the exact given value(disclosure: I'm a FOP developer, though not very active nowadays)