Reputation: 23830
So sample code:
<xsl:attribute-set name="topTableInfo">
<xsl:attribute name="font-size">10pt</xsl:attribute>
<xsl:attribute name="font-family">Helvetica</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute>
</xsl:attribute-set>
<fo:table>
<fo:table-column column-width="25mm"/>
<fo:table-column column-width="50mm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell xsl:use-attribute-sets="topTableInfo">
<fo:block margin-bottom="0.2cm" >
<xsl:value-of select="x/y"/> - <xsl:value-of select="x/z"/>
</fo:block>
</fo:table>
My issue is here:
<xsl:value-of select="x/y"/> - <xsl:value-of select="x/z"/>
I want this text to occupy maximum of 3 rows of text in this block. The text maybe 1 row or 2 row but should not exceed 3 rows. How can I do this?
x/y is generated dynamically by some input from the user.
Upvotes: 1
Views: 1135
Reputation: 8877
Based on the new comment below, the only way I can think of that works with all formatters would be to estimate the number of characters that would land you in the third line. You can be approximate, like I would choose an average amount of content and count the number of characters to place you in the middle of the third line.
Then, implement in your XSL an if to add those attributes like this:
<xsl:if test="string-length($lengthofstring) > ##">
<xsl:attribute name="height">40pt</xsl:attribute>
<xsl:attribute name="overflow">hidden</xsl:attribute>
</xsl:if>
So anything that is three lines or greater would have the height and overflow, anything less than that would not have any and would only be the height of the content.
It's not totally generic but would do the job for known widths and font sizes of content.
Upvotes: 1