docbook-apps

  • 1.  Centering Tables in Print with Fop 1.0

    Posted 11-11-2010 14:39
    I have no problems now for tables spanning the print width, nor with
    tables of any width in html. But I need to center
    less-than-page-width tables in print.

    I have used Bob Stayton's xsl fo chunk on p. 474 as a start to try to
    get my narrow tables centered in print. Here is my current version:


    <xsl:template name="table.layout">
    <xsl:param name="table.content"/>
    <fo:table width="100%" table-layout="fixed">

    <fo:table-column column-width="proportional-column-width(1)"/>

    <fo:table-column column-width="3in"/>
    <fo:table-column column-width="proportional-column-width(1)"/>
    <fo:table-body start-indent="0pt">
    <fo:table-row>



    <fo:table-cell><fo:block></fo:block></fo:table-cell>

    <fo:table-cell>

    <fo:table>
    <fo:table-body start-indent="0pt">
    <fo:table-row><fo:table-cell><fo:block>
    <xsl:copy-of select="$table.content"/>
    </fo:block></fo:table-cell></fo:table-row>
    </fo:table-body>
    </fo:table>

    </fo:table-cell>


    <fo:table-cell><fo:block></fo:block></fo:table-cell>

    </fo:table-row>
    </fo:table-body>
    </fo:table>
    </xsl:template>

    That works for the one specific table when I hardwire the actual table
    width. Is there any xsl:fo magic that can get the total original
    table width at [1]? If not I suppose I can post process the fo to fix
    it, but there must be a more elegant way.

    Thanks,

    -Tom

    Thomas M. Browder, Jr.
    Niceville, Florida
    USA



  • 2.  Re: [docbook-apps] Centering Tables in Print with Fop 1.0

    Posted 11-11-2010 22:54
    Tom
    Here is an adjusted version that triggers only when "align" is used on the table. This has some peculiarities when processed with FOP 1.0.

    I would suggest that you use fixed column widths and not proportional in the XML tables because proportional is not quite right in FOP when used in a table in a table. But if you use fixed widths it should be fine (or at least in my setup it was).

    Cheers,
    Dean Nelson



    <xsl:template name="table.layout">
    <xsl:param name="table.content"/>
    <xsl:choose>
    <xsl:when test="self::table[@align]">
    <fo:table width="100%" table-layout="fixed">
    <fo:table-column column-width="proportional-column-width(1)"/>
    <fo:table-column/>
    <fo:table-column column-width="proportional-column-width(1)"/>
    <fo:table-body start-indent="0pt">
    <fo:table-row>
    <fo:table-cell><fo:block></fo:block></fo:table-cell>
    <fo:table-cell>
    <fo:table>
    <fo:table-body start-indent="0pt">
    <fo:table-row><fo:table-cell><fo:block>
    <xsl:copy-of select="$table.content"/>
    </fo:block></fo:table-cell></fo:table-row>
    </fo:table-body>
    </fo:table>
    </fo:table-cell>
    <fo:table-cell><fo:block></fo:block></fo:table-cell>
    </fo:table-row>
    </fo:table-body>
    </fo:table>
    </xsl:when>
    <xsl:otherwise>
    <xsl:copy-of select="$table.content"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>





    In a message dated 11/11/10 06:40:35 Pacific Standard Time, tom.browder@gmail.com writes:
    I have no problems now for tables spanning the print width, nor with
    tables of any width in html. But I need to center
    less-than-page-width tables in print.

    I have used Bob Stayton's xsl fo chunk on p. 474 as a start to try to
    get my narrow tables centered in print. Here is my current version:


    <xsl:template name="table.layout">
    <xsl:param name="table.content"/>
    <fo:table width="100%" table-layout="fixed">

    <fo:table-column column-width="proportional-column-width(1)"/>

    <fo:table-column column-width="3in"/>
    <fo:table-column column-width="proportional-column-width(1)"/>
    <fo:table-body start-indent="0pt">
    <fo:table-row>



    <fo:table-cell><fo:block></fo:block></fo:table-cell>

    <fo:table-cell>

    <fo:table>
    <fo:table-body start-indent="0pt">
    <fo:table-row><fo:table-cell><fo:block>
    <xsl:copy-of select="$table.content"/>
    </fo:block></fo:table-cell></fo:table-row>
    </fo:table-body>
    </fo:table>

    </fo:table-cell>


    <fo:table-cell><fo:block></fo:block></fo:table-cell>

    </fo:table-row>
    </fo:table-body>
    </fo:table>
    </xsl:template>

    That works for the one specific table when I hardwire the actual table
    width. Is there any xsl:fo magic that can get the total original
    table width at [1]? If not I suppose I can post process the fo to fix
    it, but there must be a more elegant way.

    Thanks,

    -Tom

    Thomas M. Browder, Jr.
    Niceville, Florida
    USA

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
    For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org


  • 3.  Re: [docbook-apps] Centering Tables in Print with Fop 1.0

    Posted 11-11-2010 23:08
    On Thu, Nov 11, 2010 at 16:53, deannelson <deannelson@aol.com> wrote:
    > Tom
    > Here is an adjusted version that triggers only when "align" is used on the
    > table. This has some peculiarities when processed with FOP 1.0.
    >
    > I would suggest that you use fixed column widths and not proportional in the
    > XML tables because proportional is not quite right in FOP when used in a
    > table in a table. But if you use fixed widths it should be fine (or at least
    > in my setup it was).
    ...

    I'll try it, Dean, Thanks!

    -Tom

    Thomas M. Browder, Jr.
    Niceville, Florida
    USA