Home > Mobile >  Is it possible to wrap a text-block that does not contain whitespace?
Is it possible to wrap a text-block that does not contain whitespace?

Time:11-26

I am building an XSL for transforming some internal data into a PDF report, and one of the elements is a block that contains user-typed text of a variable length. The issue is that in the unlikely but not impossible case of the text not containing any whitespace for long enough, that part of the text cannot wrap and will simply exit the block and the page itself on the right site. See this image for how it looks in the finished PDF. Is there any way to cause the text to forcibly wrap to the next line once it reaches the end of the blocks defined width?

This is the code segment in question:

<fo:table-row>
   <fo:table-cell column-number="1" number-columns-spanned="3">
      <fo:block>Text:</fo:block>
      <fo:block-container overflow="repeat">
         <fo:block border="solid 1pt" >
            <xsl:value-of select="text"/>
         </fo:block>
      </fo:block-container>
   </fo:table-cell>
</fo:table-row>

I have attempted the various parameters of the wrap-option and the overflow attributes, to no effect.

CodePudding user response:

The usual answer for FOP is to insert a no-break space between characters so that FOP has somewhere to break.

See, e.g., How to force wrap on table entries

  • Related