You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by "Mazza, Glen R, PERSCOM" <Gl...@hoffman.army.mil> on 2002/08/15 21:53:53 UTC

centering a table on the page

Hello,

I would like to center my four-column table on the page, and have 
the table to take 50% of the page in width.

Here was my code:

<fo:table table-layout="fixed" width="50%">
<fo:table-column column-width="proportional-column-width(1)"/>
<fo:table-column column-width="proportional-column-width(1)"/>
<fo:table-column column-width="proportional-column-width(1)"/>
<fo:table-column column-width="proportional-column-width(1)"/>
...

This doesn't work (it will take up all of the width of the page, not 
just 50%) unless I hardcode the width of the table, unfortunately:

<fo:table table-layout="fixed" width="5in">
...


Questions:
1.) Can I use a table width in percentages? I'd like to use 50% 
and not hardcode the width.

2.) After getting my table to be 50% of the page, how do I then 
center the table on the page (instead of its default of left-justified)? I
know 
how to center individual fo:blocks, but not an entire table.

Thanks!
Glen

Re: centering a table on the page

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Mazza, Glen R, PERSCOM wrote:
> Hello,
> 
> I would like to center my four-column table on the page, and have 
> the table to take 50% of the page in width.

Put it into another table:
   <fo:table table-layout="fixed" width="100%">
     <fo:table-column column-width="proportional-column-width(1)"/>
     <fo:table-column column-width="proportional-column-width(2)"/>
     <fo:table-column column-width="proportional-column-width(1)"/>
     <fo:table-body>
        <fo:table-row>
           <fo:table-cell/>
           <fo:table-cell>
             <!-- your table here -->
           </fo:table-cell>
           <fo:table-cell/>
        </fo:table-row>
      ... close elements...

J.Pietschmann