pdf-generationxsl-fomultiple-columnsapache-fop

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.


Solution

  • 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.