[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Dynamic column widths on table cells

Subject: Re: [xsl] Dynamic column widths on table cells
From: "Tony Graham" <tgraham@xxxxxxxxxx>
Date: Mon, 21 Oct 2013 22:51:42 +0100 (IST)

On Mon, October 21, 2013 8:03 pm, KAATMAN Matthew wrote:
> Is it possible to have columns adjust their width based on the length of
> the content?

If your FO processor supports automatic table layout (and you haven't
forced fixed table layout [1]), then it should just work.

> I've got a situation where the right header is quite a bit longer than the
> left. I'd like it to use up the available space instead of wrapping when
> possible. (This example is set to 50/50 column width.)
> http://i.imgur.com/bgCMJYB.png
> If there's no way to automatically do it, can I manually do it based on
> content length?

Making decisions based on formatted sizes is the what we're trying to
solve at http://www.w3.org/community/ppl/wiki/FOPRunXSLTExt

> If column one was 20 chars and column 2 was 40, set them to
> proportional-column-width(1) and proportional-column-width(2) for example.

For that, you do need fixed table layout [2].

Using the lengths of the two strings should work most of the time.  Of
course 20 'W' is more than likely wider than 40 'i', but I doubt you'd use
either of those as your header text.

Another option is to discard the table and use a fo:leader between the two
strings to keep them maximally apart.


Tony Graham                                   tgraham@xxxxxxxxxx
Consultant                                 http://www.mentea.net
Mentea       13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
 --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
    XML, XSL-FO and XSLT consulting, training and programming
       Chair, Print and Page Layout Community Group @ W3C

[1] http://www.w3.org/TR/xsl11/#fo_table
[2] http://www.w3.org/TR/xsl11/#d0e5961

Current Thread