XSL-FO: Set fixed block height

Mihnea Mihai picture Mihnea Mihai · Nov 27, 2013 · Viewed 13.8k times · Source

Is there any way I can set a fixed height for a block regardless of the content within it? I have a block which sometimes displays some text but sometimes it needs to be empty and keep the same height:

<xsl:choose>
    <xsl:when test="$condition">
       <fo:block height="30mm">
          <xsl:text>TEXTTEXT</xsl:text>
       </fo:block>
    </xsl:when>
    <xsl:otherwise>
       <fo:block height="30mm">
          <xsl:text>&#160;</xsl:text>
       </fo:block>
    </xsl:otherwise>
</xsl:choose>

Answer

mzjn picture mzjn · Dec 4, 2013

The height attribute does not apply to fo:block. To keep a fixed height, wrap the fo:block in a fo:block-container:

<fo:block-container height="30mm">
 <fo:block>
   <xsl:text>&#160;</xsl:text>
 </fo:block>
</fo:block-container>