You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Roland <ro...@netquant.com.br> on 2002/03/21 20:04:53 UTC
Re: from FOP list: centered tables
At 12:26 PM 3/21/02 -0500, you wrote:
>Did you ever get a solution to this?
Yes,
what we did was the following:
A is the table you want to center. The width of A is w-a. The width of the
page is w-p.
Now make a new table B with 3 columns.
The width of the columns of B are:
1 & 3 column: (w-p - w-a)/2
2 column: w-a.
Let the 1. and 3. column be empty and put the table A into the second
column and it will make a centered table.
Cumbersome, but it works...
And we let the stylesheet do all the calculations. Just make the following
template and call it using <xsl:call-template ...>
The template will not only center tables but any "object":
<xsl:template name="makeCenteredPage">
<xsl:param name="pageW"/> <!-- the page width -->
<xsl:param name="objW"/> <!-- the object width -->
<xsl:param name="obj"/> <!-- the object itself, will be called trough a
xsl:apply template -->
<!-- make a Table with one centered column -->
<xsl:message>
makeCentered:
objW = <xsl:value-of select="$objW"/>
pageW = <xsl:value-of select="$pageW"/>
</xsl:message>
<xsl:comment> Centered table </xsl:comment>
<fo:table>
<fo:table-column column-width="{($pageW - $objW) div 2}cm"
background-color="#ffffff"/>
<fo:table-column column-width="{$objW}cm" background-color="#ffffff"/>
<fo:table-column column-width="{($pageW - $objW) div 2}cm"
background-color="#ffffff"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell number-columns-spanned="1" vertical-align="middle"
background-color="#ffffff" space-before="27pt"
padding-top="2pt"
padding-bottom="2pt" padding-left="15pt">
</fo:table-cell>
<fo:table-cell vertical-align="middle" background-color="#ffffff">
<xsl:apply-templates select="$obj"/>
</fo:table-cell>
<fo:table-cell number-columns-spanned="1" vertical-align="middle"
background-color="#ffffff" space-before="27pt"
padding-top="2pt"
padding-bottom="2pt" padding-left="15pt">
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</xsl:template>
Hope it helps you...
Roland
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org