XSL-FO fop. Long text flows into adjacent cells/block, obscuring stuff there

Alex picture Alex · Nov 23, 2010 · Viewed 37.9k times · Source

Could anyone suggest me a way to make long words (like serial numbers) to be wrapped? I tried some commercial software and there is no such issue. Is it a fop bug or probably there is a solution available?

I can't insert zero length space after each character of every word in document. This solution sounds insane for me.

Answer

Zkoh picture Zkoh · Jan 13, 2011

You can specify the wrap-option attribute in your fo:block like so:

<fo:block wrap-option="wrap"> ... stuff </fo:block>

Here's the XSL-FO specification for this attribute:

XSL Definition:

Value: no-wrap | wrap | inherit

Initial: wrap

Applies to: fo:block, fo:inline, fo:page-number, fo:page-number-citation

Inherited: yes

Percentages: N/A

Media: visual

Values have the following meanings:

no-wrap

No line-wrapping will be performed.

In the case when lines are longer than the available width of the content-rectangle, the overflow will be treated in accordance with the "overflow" property specified on the reference-area.

wrap

Line-breaking will occur if the line overflows the available block width. No special markers or other treatment will occur.

Specifies how line-wrapping (line-breaking) of the content of the formatting object is to be handled.

Implementations must support the "no-wrap" value, as defined in this Recommendation, when the value of "linefeed-treatment" is "preserve".

You can also define the wrap-option attribute in an fo:table-cell

<fo:table-cell wrap-option="wrap"> ... </fo:table-cell>

and the fo:blocks within will inherit the property.