0

I need to wrap the text to next line if it exceeds the length of the table cell in XSL-FO.

Sample XSL-FO:

    <fo:table-row>
       <fo:table-cell padding-bottom="3px" text-align="right" width="4cm" margin="0" margin-right="0.27cm">
        <fo:block-container>
            <fo:block >
                <fo:inline>Herewith: </fo:inline>
            </fo:block>
        </fo:block-container>
    </fo:table-cell>
    <fo:table-cell  padding-bottom="3px" text-align="left" width="7cm" margin="0" margin-left="-0.22cm">
        <fo:block-container>
            <fo:block>
                <fo:inline  font-family="FrutigerLTStd-Bold" font-weight="bold">
                    <xsl:value-of select="herewith"/>
                </fo:inline>                                                    
            </fo:block>
        </fo:block-container>
    </fo:table-cell>

Here if table cell value somethingxhsjdjfjkshkjkh" values exceeds, it will not wrap it into next line until we give some space between the values. I tried with wrap-option="wrap". But if there is a space in values only, then it will bring it to next line.

Can anyone help on this?

potame
  • 7,597
  • 4
  • 26
  • 33
  • 3
    Which rendering engine are you using? FOP? Antenna House Formatter? Other? Did you have a look at https://stackoverflow.com/questions/4350788/xsl-fo-force-wrap-on-table-entries? – potame Dec 18 '15 at 15:53
  • With the markup as currently shown, the `fo:block-container` and the first `fo:inline` are redundant. If you move the `@font-family` and `@font-weight` to the containing `fo:block`, then the second `fo:inline` becomes redundant as well. Setting `font-family="FrutigerLTStd-Bold"` and `font-weight="bold"` is also almost certainly redundant, both since "FrutigerLTStd-Bold" would be bold anyway and since your formatter should be able to find the bold variant if you instead had `font-family="FrutigerLTStd"` and `font-weight="bold"`. – Tony Graham Dec 18 '15 at 17:15
  • 1
    This question is asked and answered at http://stackoverflow.com/questions/4350788/xsl-fo-force-wrap-on-table-entries/4533760#4533760 as @potame has pointed out – Kevin Brown Dec 18 '15 at 23:31

1 Answers1

0

If your formatter supports hyphenation and the text is able to be hyphenated, then enabling hyphenation will help.

If it's allowed for you to change the column widths, then enabling automatic table layout (http://www.w3.org/TR/xsl11/#fo_table) may let the formatter squeeze the width of the other columns and increase the width of this column so that this text doesn't overflow.

Tony Graham
  • 7,306
  • 13
  • 20