I'm at a loss trying to understand this. I'm new to using xsl-fo (apache-fop implementation) and I want a block with a border and the content inside padded so it's not bumped up against the border. However when I add the padding, the padding is also applied to the following block?
<fo:page-sequence master-reference="report-page">
<fo:flow flow-name="xsl-region-body">
<fo:block border="1px solid black" font-size="8pt" margin-bottom="3mm" padding="3mm" >
<fo:block font-weight="bold">FOO</fo:block>
<fo:block>ANOTHER BLOCK</fo:block>
</fo:block>
<fo:block font-size="8pt">BAR</fo:block>
</fo:flow>
Why does BAR become indented by the amount of padding from the previous block? If I remove the padding on the first block, things line up fine?
What you should be doing is setting margin to "0mm" and padding to "3mm" on the block if your intention is to have no space outside the border and a 3mm space between the text and the border.
<fo:block border="1px solid black" font-size="8pt" margin="0mm" padding="3mm">
<fo:block font-weight="bold">FOO</fo:block>
</fo:block>
If the margin-bottom was intended to make space between elements, then you would use space-after or space-before on the following element.
Try to do the following (this is not tested because my Apache FOP installation is not within reach...)
EDIT : Now tested. Padding is only applied to the first block ("FOO").
Specify the padding inside a fo:inline element like this:
<fo:block border="1px solid black" margin-bottom="3mm">
<fo:inline padding="3mm" font-size="8pt" font-weight="bold">
<fo:block>FOO</fo:block>
</fo:inline>
</fo:block>
Also, I've moved the font-weight and font-size properties to the inline element, since the inner block is the only place they are needed (at least in your simple snippet). The outer block only defines the border. Let me know if this works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With