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

6

12

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.

Kristy answered 23/11, 2010 at 4:37 Comment(0)
F
13

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.

Frasquito answered 13/1, 2011 at 11:26 Comment(1)
wrap-option="wrap" tells the formatter to perform line-breaking, but it is not a guarantee that line-breaking will find a suitable place for a line break; moreover, wrap is the default property value, so it's usually unnecessary to explicitly set it.Aldous
R
11

Zkoh's answer (wrapping) 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 the way to go (as Daniel suggested).

There can be quite a few problems with hyphenation in FOP:

  1. FOP is using hyphenation algorithms from TeX and because of some licencing issues, those algorithms (at least for some languages) are not part of standard FOP binary distribution (as stated here) and must be downloaded separately from OFFO web site. There are two kinds of hyphenation pattern files on the website. XML format (which needs to be compiled 1st to be used with FOP) and JAR file (already compiled). Be sure to download compiled version! Installation is straightforward and well documented - just drop the OFFO binary into FOP's lib folder and thats it...
  2. Don't forget to specify language of your document and if needed, enable hyphenation on block level (its inherited so add it to the root element and you should be fine) - see FOP FAQ
Reeba answered 4/1, 2014 at 7:34 Comment(1)
This should be the accepted answer. The OFFO web site specified here is down, here is another link to OFFO. Also, as mentioned, the language xml:lang="en" should be added to the root of your file (this was hard to figure out...).Coffeng
P
6

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).

Pneumato answered 23/11, 2010 at 5:52 Comment(0)
V
3

Use keep-together.within-column="always" instead of keep-together="always" of to keep long lines with in table cell.

Volney answered 5/6, 2014 at 11:54 Comment(0)
D
1

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.

Decani answered 15/8, 2018 at 22:13 Comment(0)
A
0

For text overflow problem use keep-together="auto" attribute.enter image description here

Text Overflow Issue

enter image description here

Fixed version after using keep-together="auto" attribute.

Ardene answered 3/10, 2019 at 11:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.