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 Jason R Briggs <ja...@rhe.co.nz> on 2006/03/01 23:23:33 UTC

complex table layout problem

Hi all

I am reproducing a rather complicated layout which requires a number of 
nested tables:

Basically the page looks something like this (a header with 2 columns, 
followed by a table with 4 columns, 2 columns spanning 2 rows, and one 
cell spanning 2 columns):


------------------------------------------
headerleft                    headerright
------------------------------------------

*------*  *---*  *-------------*  *------*
|      |  |   |  |             |  |      |
|      |  |   |  |             |  |      |
|      |  *---*  *-------------*  |      |
|      |                          |      |
|      |  *--------------------*  |      |
|      |  |                    |  |      |
*------*  *--------------------*  *------*

The problem is that the column for headerright is proving impossible to 
align.  I have tried separating the header and content sections into 2 
tables, plus making the header a single cell spanning the 4 cells (the 
columns in the main section) and then using a nested table inside the 
header as well.  But what I always end up with is:

-------------------------------------------------------
headerleft                                 headerright
-------------------------------------------------------

*------*  *---*  *-------------*  *------*
|      |  |   |  |             |  |      |
|      |  |   |  |             |  |      |

(where header right actually goes off the page boundaries.  It seems 
that the first cell in the nested table grows to fill the size of the 
surrounding table, then the second cell added pushes off outside that 
region.

I hope that makes sense?  Anyway below is the fo-xml for the header 
region at the moment.  I've been playing different methods of doing this 
for the last day or so, with no progress  (as a matter of interest I ran 
it through an eval copy of a commercial app and, while not perfect, it 
renders more how I was expecting).  Is this a known bug -- or have I 
done something stupid?

Thanks once again
Jason


<fo:table-cell number-columns-spanned="4" padding="3px">
   <fo:table>
     <fo:table-body>
       <fo:table-row>
         <fo:table-cell border-top="0.2mm solid black" 
border-bottom="0.2mm solid black">
           <fo:table>
             <fo:table-body>
               <fo:table-row>
                 <fo:table-cell>
                   <fo:block><fo:inline font-weight="bold">Report 
for:</fo:inline> demo</fo:block>
                 </fo:table-cell>
                 <fo:table-cell>
                   <fo:block></fo:block>
                 </fo:table-cell>
               </fo:table-row>
               <fo:table-row>
                 <fo:table-cell>
                   <fo:block><fo:inline 
font-weight="bold">Group:</fo:inline> blah</fo:block>
                 </fo:table-cell>
                 <fo:table-cell>
                   <fo:block><fo:inline 
font-weight="bold">Date:</fo:inline> 25 Jan 2006</fo:block>
                 </fo:table-cell>
               </fo:table-row>
             </fo:table-body>
           </fo:table>
         </fo:table-cell>
       </fo:table-row>
     </fo:table-body>
   </fo:table>
</fo:table-cell>


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: complex table layout problem

Posted by Jason R Briggs <ja...@rhe.co.nz>.
Hi Manuel

Sorry forgot to mention I'm using TRUNK.

I just went through my xml and explicitly set widths on all my nested 
tables.  Looks like it now produces the output I'm expecting.

Thanks for the help.

J

Manuel Mall wrote:
> Jason,
> 
> firstly you didn't say which version of FOP you are using.
> 
> Secondly, neither version of FOP supports HTML like automatic table layout
> i.e. column width determination based on column content.
> 
> To achieve what you want you need to specify column widths and table
> widths. In particular under every <fo:table element you should have a
> <fo:table-column width="..."/> element for each column in your table
> specifying the width of your column.
> 
> If you need proportional column widths (similar to HTML percentages) use
> the proportional-column-width() function in the witdh="..." attribute
> value specification.
> 
> So your header table would look something like (this is not tested!):
> 
> <fo:table width="200mm" table-layout="fixed" border-separation="separate">
>   <fo:table-column width="proportional-column-width(1)" />
>   <fo:table-column width="proportional-column-width(1)" />
>   <fo:table-body>
>     <fo:table-row>
>       <fo:table-cell>
>         <fo:block text-align="left">headerleft</fo:block>
>       </fo:table-cell>
>       <fo:table-cell>
>         <fo:block text-align="right">headerright</fo:block>
>       </fo:table-cell>
>     </fo:table-row>
>   <fo:table-body>
> </fo:table>
> 
> followed by the main table like:
> 
> <fo:table width="200mm" table-layout="fixed" border-separation="separate">
>   <fo:table-column width="40mm" />
>   <fo:table-column width="20mm" />
>   <fo:table-column width="100mm" />
>   <fo:table-column width="40mm" />
>   <fo:table-body>
>     <fo:table-row>
>       <fo:table-cell number-rows-spanned="2">...</fo:cell>
>       <fo:table-cell>...</fo:cell>
>       <fo:table-cell>...</fo:cell>
>       <fo:table-cell number-rows-spanned="2">...</fo:cell>
>     </fo:tabe-row>
>     <fo:table-row>
>       <fo:table-cell number-columns-spanned="2">...</fo:cell>
>     </fo:tabe-row>
>   <fo:table-body>
> </fo:table>
> 
> Manuel
> 
> 
>>Hi all
>>
>>I am reproducing a rather complicated layout which requires a number of
>>nested tables:
>>
>>Basically the page looks something like this (a header with 2 columns,
>>followed by a table with 4 columns, 2 columns spanning 2 rows, and one
>>cell spanning 2 columns):
>>
>>
>>------------------------------------------
>>headerleft                    headerright
>>------------------------------------------
>>
>>*------*  *---*  *-------------*  *------*
>>|      |  |   |  |             |  |      |
>>|      |  |   |  |             |  |      |
>>|      |  *---*  *-------------*  |      |
>>|      |                          |      |
>>|      |  *--------------------*  |      |
>>|      |  |                    |  |      |
>>*------*  *--------------------*  *------*
>>
>>The problem is that the column for headerright is proving impossible to
>>align.  I have tried separating the header and content sections into 2
>>tables, plus making the header a single cell spanning the 4 cells (the
>>columns in the main section) and then using a nested table inside the
>>header as well.  But what I always end up with is:
>>
>>-------------------------------------------------------
>>headerleft                                 headerright
>>-------------------------------------------------------
>>
>>*------*  *---*  *-------------*  *------*
>>|      |  |   |  |             |  |      |
>>|      |  |   |  |             |  |      |
>>
>>(where header right actually goes off the page boundaries.  It seems
>>that the first cell in the nested table grows to fill the size of the
>>surrounding table, then the second cell added pushes off outside that
>>region.
>>
>>I hope that makes sense?  Anyway below is the fo-xml for the header
>>region at the moment.  I've been playing different methods of doing this
>>for the last day or so, with no progress  (as a matter of interest I ran
>>it through an eval copy of a commercial app and, while not perfect, it
>>renders more how I was expecting).  Is this a known bug -- or have I
>>done something stupid?
>>
>>Thanks once again
>>Jason
>>
>>
>><fo:table-cell number-columns-spanned="4" padding="3px">
>>   <fo:table>
>>     <fo:table-body>
>>       <fo:table-row>
>>         <fo:table-cell border-top="0.2mm solid black"
>>border-bottom="0.2mm solid black">
>>           <fo:table>
>>             <fo:table-body>
>>               <fo:table-row>
>>                 <fo:table-cell>
>>                   <fo:block><fo:inline font-weight="bold">Report
>>for:</fo:inline> demo</fo:block>
>>                 </fo:table-cell>
>>                 <fo:table-cell>
>>                   <fo:block></fo:block>
>>                 </fo:table-cell>
>>               </fo:table-row>
>>               <fo:table-row>
>>                 <fo:table-cell>
>>                   <fo:block><fo:inline
>>font-weight="bold">Group:</fo:inline> blah</fo:block>
>>                 </fo:table-cell>
>>                 <fo:table-cell>
>>                   <fo:block><fo:inline
>>font-weight="bold">Date:</fo:inline> 25 Jan 2006</fo:block>
>>                 </fo:table-cell>
>>               </fo:table-row>
>>             </fo:table-body>
>>           </fo:table>
>>         </fo:table-cell>
>>       </fo:table-row>
>>     </fo:table-body>
>>   </fo:table>
>></fo:table-cell>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
>>For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>>
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: complex table layout problem

Posted by Manuel Mall <ma...@apache.org>.
Jason,

firstly you didn't say which version of FOP you are using.

Secondly, neither version of FOP supports HTML like automatic table layout
i.e. column width determination based on column content.

To achieve what you want you need to specify column widths and table
widths. In particular under every <fo:table element you should have a
<fo:table-column width="..."/> element for each column in your table
specifying the width of your column.

If you need proportional column widths (similar to HTML percentages) use
the proportional-column-width() function in the witdh="..." attribute
value specification.

So your header table would look something like (this is not tested!):

<fo:table width="200mm" table-layout="fixed" border-separation="separate">
  <fo:table-column width="proportional-column-width(1)" />
  <fo:table-column width="proportional-column-width(1)" />
  <fo:table-body>
    <fo:table-row>
      <fo:table-cell>
        <fo:block text-align="left">headerleft</fo:block>
      </fo:table-cell>
      <fo:table-cell>
        <fo:block text-align="right">headerright</fo:block>
      </fo:table-cell>
    </fo:table-row>
  <fo:table-body>
</fo:table>

followed by the main table like:

<fo:table width="200mm" table-layout="fixed" border-separation="separate">
  <fo:table-column width="40mm" />
  <fo:table-column width="20mm" />
  <fo:table-column width="100mm" />
  <fo:table-column width="40mm" />
  <fo:table-body>
    <fo:table-row>
      <fo:table-cell number-rows-spanned="2">...</fo:cell>
      <fo:table-cell>...</fo:cell>
      <fo:table-cell>...</fo:cell>
      <fo:table-cell number-rows-spanned="2">...</fo:cell>
    </fo:tabe-row>
    <fo:table-row>
      <fo:table-cell number-columns-spanned="2">...</fo:cell>
    </fo:tabe-row>
  <fo:table-body>
</fo:table>

Manuel

> Hi all
>
> I am reproducing a rather complicated layout which requires a number of
> nested tables:
>
> Basically the page looks something like this (a header with 2 columns,
> followed by a table with 4 columns, 2 columns spanning 2 rows, and one
> cell spanning 2 columns):
>
>
> ------------------------------------------
> headerleft                    headerright
> ------------------------------------------
>
> *------*  *---*  *-------------*  *------*
> |      |  |   |  |             |  |      |
> |      |  |   |  |             |  |      |
> |      |  *---*  *-------------*  |      |
> |      |                          |      |
> |      |  *--------------------*  |      |
> |      |  |                    |  |      |
> *------*  *--------------------*  *------*
>
> The problem is that the column for headerright is proving impossible to
> align.  I have tried separating the header and content sections into 2
> tables, plus making the header a single cell spanning the 4 cells (the
> columns in the main section) and then using a nested table inside the
> header as well.  But what I always end up with is:
>
> -------------------------------------------------------
> headerleft                                 headerright
> -------------------------------------------------------
>
> *------*  *---*  *-------------*  *------*
> |      |  |   |  |             |  |      |
> |      |  |   |  |             |  |      |
>
> (where header right actually goes off the page boundaries.  It seems
> that the first cell in the nested table grows to fill the size of the
> surrounding table, then the second cell added pushes off outside that
> region.
>
> I hope that makes sense?  Anyway below is the fo-xml for the header
> region at the moment.  I've been playing different methods of doing this
> for the last day or so, with no progress  (as a matter of interest I ran
> it through an eval copy of a commercial app and, while not perfect, it
> renders more how I was expecting).  Is this a known bug -- or have I
> done something stupid?
>
> Thanks once again
> Jason
>
>
> <fo:table-cell number-columns-spanned="4" padding="3px">
>    <fo:table>
>      <fo:table-body>
>        <fo:table-row>
>          <fo:table-cell border-top="0.2mm solid black"
> border-bottom="0.2mm solid black">
>            <fo:table>
>              <fo:table-body>
>                <fo:table-row>
>                  <fo:table-cell>
>                    <fo:block><fo:inline font-weight="bold">Report
> for:</fo:inline> demo</fo:block>
>                  </fo:table-cell>
>                  <fo:table-cell>
>                    <fo:block></fo:block>
>                  </fo:table-cell>
>                </fo:table-row>
>                <fo:table-row>
>                  <fo:table-cell>
>                    <fo:block><fo:inline
> font-weight="bold">Group:</fo:inline> blah</fo:block>
>                  </fo:table-cell>
>                  <fo:table-cell>
>                    <fo:block><fo:inline
> font-weight="bold">Date:</fo:inline> 25 Jan 2006</fo:block>
>                  </fo:table-cell>
>                </fo:table-row>
>              </fo:table-body>
>            </fo:table>
>          </fo:table-cell>
>        </fo:table-row>
>      </fo:table-body>
>    </fo:table>
> </fo:table-cell>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org