Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XSL-FO dynamic table column width

As it stands now, I have about 12 columns and all of them are exactly the same width. The problem is that some columns don't require that much space. How do I get the columns to fit their content? The columns need to be a dynamic width.

I've tried

<fo:table table-layout="auto">

And

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

Nothing seems to do the trick.

like image 689
SeanWM Avatar asked Feb 14 '13 14:02

SeanWM


2 Answers

Unfortunately I didn't find a simple way to have dynamic column widths. I ended up with this:

<fo:table-column column-number="1"  column-width="35pt" />
<fo:table-column column-number="2"  />
<fo:table-column column-number="3"  />
<fo:table-column column-number="4"  />
<fo:table-column column-number="5"  />
<fo:table-column column-number="6"  />
<fo:table-column column-number="7"  />
<fo:table-column column-number="8"  />
<fo:table-column column-number="9"  />
<fo:table-column column-number="10" />
<fo:table-column column-number="11" />
<fo:table-column column-number="12" />

I specify the first column because the data will never change. The rest I leave open to fit their content. Works the way I need it to work for now.

like image 73
SeanWM Avatar answered Oct 06 '22 01:10

SeanWM


You can also specify the units in "percent units". Works fine for me...

<fo:table-column column-number="1" column-width="75%" /> 
<fo:table-column column-number="2" column-width="25%" />
like image 43
Raman Sahasi Avatar answered Oct 06 '22 03:10

Raman Sahasi