W3C home > Mailing lists > Public > www-xsl-fo@w3.org > June 2010

Distributing vertical space within flowed tables?

From: Craig Ringer <craig@postnewspapers.com.au>
Date: Tue, 22 Jun 2010 08:36:28 +0800
Message-ID: <4C20058C.50104@postnewspapers.com.au>
To: www-xsl-fo@w3.org
Hi all

I'm fairly new to XSL-FO, so if this is a stupid question please accept
my apologies in advance. I've read endless XSL-FO docs (including the
.... dense ... spec), the Apache FOP FAQ, and searched the archives of
this list, the fop list, and the xsl-fo Yahoo group, so I'm not popping
up without doing some research.

The short version is that I can't figure out how to distribute vertical
space to avoid ragged column bottoms in multi-column pages when the flow
contains several long-ish one-column tables. Why one-column tables?
Because I have sections with headings that must be repeated at the top
of a column if split across columns.

I'm writing a (to be open source) app to automatically paginate
classified ads to PDF, as I've been unable to find an acceptable
commercial solution at a reasonable price or locate any decent OSS
offering. I'm trying to use XSL-FO for layout, and need to produce
multi-column output, with column content flowing from bottom-left to
top-right along the columns. I'm using <fo:simple-page-master
column-count="7" ... /> to achieve that with no fuss.

The content is blocks of text and graphics that either have large
widow/orphan limits or cannot be split across columns at all, so elastic
spacing is required to avoid huge ragged blobs of whitespace at the
bottom of columns. This is easy enough using elastic space-before[1] if
each ad is in its own <fo:block> that's directly flowed into the column.

The tricky bit is that these collections of text blocks and images are
grouped into classifications, each of which must have a heading. If the
classification spans more than one column, **the heading must be
repeated at the top of the column**. I'm satisfying this requirement by
putting the ads in each classification into a one-column table and using
<fo:table-header/> to provide a repeating header. It's ugly, but it works.

However, I can't figure out how to specify elastic spacing to distribute
space between rows in the table and between tables. Table rows don't
have a space-before attribute. Adding elastic space-before to the
<fo:block/> within each table cell appears to have no effect. And
there's no display-align="justify" that would spread spacing evenly
line-by-line within all objects [2], as would be ideal. I can specify
elastic space-before for each table as a whole, but to have much effect
I need so much space that large holes open up between tables, while the
rows within the tables remain cramped.

(a) I need elastic spacing to prevent big, uneven chunks of whitespace
at the bottom of columns; but

(b) I need to repeat classification headings at the top of columns, and
can only seem to do that with 1-column tables, the use of which seems to
prevent effective elastic spacing.


I've been trying to figure out a way to use the
block-progression-dimension attribute to achieve this, as it seems to be
a more generalized form of elastic sizing. However, I just can't figure
out how to use it to express a flexible "expansion" amount. To use it, I
seem to already have to know how big the block needs to be to hold its
contents, so I can set the minimum, optimum, and maximum appropriately.

Is there any way to do this? Or am I barking up the wrong tree entirely?

Is there a way to achieve repeating column headings that'll let me avoid
wrapping sections (classifications) up in one-column tables, so I can
use the usual elastic spacing mechanism?

Is there any notional equivalent of display-align="justify" ? And if so,
any way to limit that justification or set a threshold of whitespace
percentage over which it won't try to do it?


Since I know how frustrating it is to see such questions without
concrete code: here's a sample XSL-FO document, generated from last
weeks' newspapers published classified ads:

  http://www.postnewspapers.com.au/~craig/fo_question/cl_pdf.fo

and the PDF fop produces for it:

  http://www.postnewspapers.com.au/~craig/fo_question/cl_pdf.pdf

The FO and PDF for another advertising section is also present, but is
less useful because it requires a huge bunch of referenced images to
paginate:

  http://www.postnewspapers.com.au/~craig/fo_question/tr_pdf.fo
  http://www.postnewspapers.com.au/~craig/fo_question/tr_pdf.pdf

( In that directory there's also an XSLT transform (ads_to_fo.xml) and
the source xml (cl.xml and tr.xml), not that it's really relevant to the
question. )


[1]
http://old.nabble.com/display-align%3D%22justify%22-ts8772141.html#a8772141

[2]http://article.gmane.org/gmane.text.xml.fop.user/25707

--
Craig Ringer
Received on Tuesday, 22 June 2010 13:00:59 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 22 June 2010 13:01:01 GMT