Maneesh
Maneesh

Reputation: 149

How to wrap continuous text of data?

I am using Apache's FOP library to generate a PDF from an XML. I have a <fo:block> on which I am using a wrap-option="wrap". In the XML, if the field from which this block gets the value has any line breaks or whitespaces, it wraps the text. But, if there are no line breakers/whitespaces/tabs etc., it does not wrap.

How can I achieve wrapping such data that has no line-breakers/whitespaces/tabs?

Upvotes: 1

Views: 2333

Answers (1)

lfurini
lfurini

Reputation: 3788

The property wrap-option="wrap" does not force the processor to break the text into lines at certain positions, it just states (XSL-FO specifications, § 7.16.13 "wrap-option"):

Line-breaking will occur if the line overflows the available block width

Note also that "wrap" is the default property value, so there is no need to explicitly set it, unless the inherited value would be "no-wrap".

In order for the line breaking to actually build several lines, the text must have some feasible break positions: "regular" spaces, linefeeds, hyphenation points ...

If your field values have no spaces and you cannot enable hyphenation (for example because they are long numbers / alphanumeric strings) you can add zero-width spaces (&#x200B;) during the XSLT transformation: these characters constitute valid break positions, and are otherwise invisible.

Upvotes: 1

Related Questions