XSL-FO: How to set dynamic table width?

I have this problem: I need a FO-table, which is just as wide as the width of the content (cells). But when I add a table in my FO-markup, it is always acting like a Block-Level-Element and using the width of the wohle row. Confusing for me: If I wrap it into an Inline-Element (which has the expected behavior), the Table has not the behavior of the Inline-Element but turns again to be a Block-Element. Does someone has an idea of how to solve that? Here my markup:

           Image name 1         Image name 2         Image name 3         image name4   

(Maybe important notice: My columns need to be toggling with fixed and auto-width) Thank you already.

3,776 4 4 gold badges 33 33 silver badges 50 50 bronze badges asked Feb 10, 2015 at 10:50 153 1 1 gold badge 1 1 silver badge 10 10 bronze badges

I added the FO-snippet, as the whole document is very big. Is that enough? Processor I am using is FOP 1.1

Commented Feb 10, 2015 at 12:29

My table is as you wrote alternating image (with a fixed width) and text (width depending of the text), and all in one row.

Commented Feb 11, 2015 at 11:34

1 Answer 1

What you need is called automatic table layout and is theoretically achieved setting inline-progression-dimension and table-layout to auto :

 . columns, table-body . 

However, FOP does not support auto layout yet; if you don't set a width for the table the whole line width will be used, and will be divided between the columns according to their column-width (either fixed or as a percentage), or in equal parts if columns don't have an explicitly set width.

Confusing for me: If I wrap it into an Inline-Element (which has the expected behavior), the Table has not the behavior of the Inline-Element but turns again to be a Block-Element.

An fo:table always creates block areas, and wrapping it inside an fo:inline is not going to change that.

Edit: workaround

In the specific case of a single row of objects (as in the question) a table might not be needed at all, and the desired output could be achievable using just inline objects:

  Image name 1 Image name 2 Image name 3 Image name 4