atos88
atos88

Reputation: 21

How to make a two column paragraph kept together on a page?

I got stuck with a problem using XSL-FO to generate a PDF.

I have a document with two columns and I want to make a paragraph (which can start on the bottom of a page if there is space) to be kept on one page, without any page breaks. The main purpose would be to shift the paragraph to the next page. I can not use declared page-break before the paragraph because the previous contents are dynamic. The text itself has one line break which has to be kept(white-space-collapse=false) and there is a spanned line after it to make it displayed in two columns on the top of the page. Things I already tried:

The base xsl-fo code of the paragraph which has to be modified to be kept on one page:

<fo:block font-family="Font name" font-size="8.5pt" font-weight="normal" keep-with-next.within-column="always" line-height="10.5pt" orphans="5" text-align="left" widows="5">
<fo:block white-space-collapse="false">TEXT IN TWO COLUMNS</fo:block>

I can change the attributes of each block but changing the first one only would be the optimal solution.

Thanks in advance :]

Upvotes: 2

Views: 2082

Answers (2)

Hayra
Hayra

Reputation: 466

Have you tried with

keep-with-previous.within-column="always"

It will firstly check the previous column then make the arrangement according to that.

Upvotes: 1

G. Ken Holman
G. Ken Holman

Reputation: 4393

keep-together.within-column="always" should give you what you need without leaving orphaned lines, and it is an inherited property and so need not be specified on every block if it is specified on an ancestral block. However, in your code snippet, you have specified keep-with-next= which is not inherited.

Only some properties are inherited, not all. Check pages 440/441 of my XSL-FO book, a "try and buy" version found for free at http://www.CraneSoftwrights.com/training/#pfux (note the page numbers are for the A4 version; see pages 438/439 of the US-letter version).

Upvotes: 2

Related Questions