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.
Zkoh's answer (wraping) will help you only if the text contains multiple words split by white spaces. In case of long words (as mensioned in question), hyphenation is way to go (as Daniel suggested).
There can be quite a few problems with hyphenation in FOP:
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:block
s within will inherit the property.
Would hyphenation solve your problem? You should be able to enable hyphenation with a hyphenate="true"
attribute. Placement of this attribute will depend on where you want to enable hyphenation.
Here's a link to FOP's hyphenation compliance: Apache FOP Compliance Page
Here's a link to the XSL spec: XSL Spec #hyphenate
If not, you may need to experiment with some keeps properties (like keep-together.within-line
).
Use keep-together.within-column="always" instead of keep-together="always" of to keep long lines with in table cell.
The question is about serial numbers, not about dictionary words. Specifying hyphenate="true"
is useful only when the hyphenation dictionary or hyphenation algorithm can successfully hyphenate the words in the text. Serial numbers would rarely generate sequences that can usefully be hyphenated as if they are words.
You can, of course, use XSLT to add zero-width spaces in text in table cells rather than doing it manually. StackOverflow likes duplicate questions (see https://stackoverflow.blog/2010/11/16/dr-strangedupe-or-how-i-learned-to-stop-worrying-and-love-duplication/), but, all the same, please see the answers in XSL-FO: Force Wrap on Table Entries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With