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

后端 未结 6 1522
灰色年华
灰色年华 2020-12-11 02:37

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 probabl

相关标签:
6条回答
  • 2020-12-11 02:48

    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.

    0 讨论(0)
  • 2020-12-11 02:48

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

    0 讨论(0)
  • 2020-12-11 02:54

    For text overflow problem use keep-together="auto" attribute.

    Text Overflow Issue

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

    0 讨论(0)
  • 2020-12-11 02:56

    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.

    0 讨论(0)
  • 2020-12-11 03:10

    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:

    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
    0 讨论(0)
  • 2020-12-11 03:10

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

    0 讨论(0)
提交回复
热议问题