Search code examples
xsltxsl-foapache-fop

How to remove/reduce default spacing between table rows in fo:table while generating PDF


I would like to reduce the line space between the rows in a fo:table. I tried using top, bottom on each row and space-before and space-after on fo:block and had no effect.

<xsl:template match="region1">
   	<fo:static-content flow-name="xsl-region-before" >
		<fo:table table-layout="fixed" width="100%">
			<fo:table-column column-width="100%"/>
			<!-- <fo:table-column column-width="20%"/>  -->
			<fo:table-body>
				<fo:table-row><fo:table-cell><fo:block font-family="Courier" font-style="normal" font-weight="bold" white-space="pre" font-size="12pt"><xsl:value-of select="lines[1]/line"/></fo:block></fo:table-cell></fo:table-row>
				<fo:table-row><fo:table-cell><fo:block font-family="Courier" font-style="normal" font-weight="bold" white-space="pre" font-size="12pt"><xsl:value-of select="lines[2]/line"/></fo:block></fo:table-cell></fo:table-row>
				<fo:table-row><fo:table-cell><fo:block font-family="Courier" font-style="normal" font-weight="bold" white-space="pre" font-size="12pt"><xsl:value-of select="lines[3]/line"/></fo:block></fo:table-cell></fo:table-row>
				<fo:table-row><fo:table-cell><fo:block font-family="Courier" font-style="normal" font-weight="bold" white-space="pre" font-size="12pt"><xsl:value-of select="lines[4]/line"/></fo:block></fo:table-cell></fo:table-row>
				<fo:table-row><fo:table-cell><fo:block font-family="Courier" font-style="normal" font-weight="bold" white-space="pre" font-size="12pt"><xsl:value-of select="lines[5]/line"/></fo:block></fo:table-cell></fo:table-row>
			</fo:table-body>
		</fo:table>
    </fo:static-content>
</xsl:template>

WHat I am getting is:enter image description here

What is expected is: enter image description here


Solution

  • The default line height which is the leading is probably 1.2 times the font size. Set line-height more appropriate to your case like maybe even line-height=0