13

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.

SeanWM
  • 16,789
  • 7
  • 51
  • 83
  • If you are using FOP, it won't work. FOP doesn't support `table-layout="auto"`. – mzjn Feb 14 '13 at 14:45
  • Thanks! Any idea for the question itself? – SeanWM Feb 14 '13 at 14:48
  • 1
    Buy a commercial formatter that supports `table-layout="auto"`, such as XEP (http://www.renderx.com/tools/xep.html). There are also free personal and academic editions for non-commercial use: http://www.renderx.com/download/personal.html. – mzjn Feb 14 '13 at 14:52

3 Answers3

15

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.

SeanWM
  • 16,789
  • 7
  • 51
  • 83
3

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%" />
Raman Sahasi
  • 30,180
  • 9
  • 58
  • 71
0
  1. Use the attribute 'proportional-column-width' for lengthy columns and remaining columns let be default.
  2. Check the width of the each columns, If it is lengthy than other columns, provide how many times bigger (like 2 times or 3 times or 4.5 times or even more).

Ex-1 :

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

Ex-2 :

<fo:table-column column-number="1" column-width="proportional-column-width(3)"/>
<fo:table-column column-number="2" column-width="proportional-column-width(4)"/>
<fo:table-column column-number="3"/>
slfan
  • 8,950
  • 115
  • 65
  • 78
J. WILLIAM
  • 11
  • 1