开发者

XSL-FO: Table layout tweaking

开发者 https://www.devze.com 2023-01-08 21:16 出处:网络
Here is my problem, I have a table like this This is a column header (A)| Another Column header (B) | Header (C) | Another column Header (D)

Here is my problem, I have a table like this

This is a column header (A)  | Another Column header (B) | Header (C) | Another column Header (D)
--------------------------------------------------------------------------------------------------
Value A                      | Value B                   |  Value C   | Value D

The thing is, the values in columns A and C, say can be very long whereas the values in B and D can be very short. I don't mind if the headers or the values wrap - so ideally I would like a typical table to look like the following

This is a column header (A)             | Another       | Header (C)                        | Another 
                                        | Column        |                                   | column 
                                        | header (B)    |                                   | Header (D)
----------------------------------------------------------------------------------------------------------
Value is very long and verbose, bla bla | Value B       | Value C - this to is quite long   | Value D
bla bla bla - see it wrapped            |               |                                   |

Essentially, I would like the column headers to wrap in preference to the values in the table data cells. I cannot simply apply the wrap-option="no-wrap" attribute to the t开发者_StackOverflow社区able cells - as the page is not wide enough to accommodate all the long text.

I have tried specifying proportional-column-width attribute to the columns - but this is not ideal as I don't know which columns will contain the longest text in all circumstances.

The best solution that I have come up with at the moment, is to explicitly put line breaks in the column header text but this has the unwanted side effect that it seems to increase the column width a fair amount. See http://snipplr.com/view/37957/xslfo-to-make-a-table/ for an example. This produces this output http://imagebin.org/106996 . Note how columns3, 4, 5, 6 and 7 seem to have rather generous padding, which means that columns1 and 2 are narrower than they could be.

Any help would be greatly appreciated.

PS - I am using the Ibex rendering engine http://www.xmlpdf.com


I'm not sure which rendering engine you're using. But if it supports table-layout="auto" (which most commersial engines does) this might give you a better result than the result you get now. Without any explict line breaks.

See the XSL specification for table-layout property and the corresponding CSS2 specification.

0

精彩评论

暂无评论...
验证码 换一张
取 消