XFA Rich Text Wrapping
The rich text draw pipeline lays XHTML paragraph text into consecutive lines using the draw width, effective paragraph margins and the first-line textIndent
Unicode line-break opportunities apply across adjacent span elements, including between ideographs and after permitted punctuation. Nonbreaking spaces and word joiners suppress soft wraps. An overlong unbroken segment wraps at measured Unicode grapheme boundaries. A cluster wider than the available line stays together, including combining marks and emoji joined with a zero-width joiner
Normal XHTML spaces, tabs and source line endings collapse to one space, and spaces at the beginning or end of a line are omitted. A br element or a Unicode mandatory separator forces a line break, and consecutive breaks retain empty intermediate lines. Zero-width spaces allow a soft wrap without emitting a visible character
Paragraphs accept inline CSS white-space: normal, nowrap and pre-line. A paragraph inherits the setting from its XHTML body unless it supplies a supported override. nowrap collapses whitespace and lets text overflow the available width between forced breaks. pre-line collapses horizontal whitespace, preserves source newlines, and still wraps where the line width requires it
Inline XHTML elements such as span and a can override the inherited white-space mode for their text and descendants. A collapsible space uses its containing element's mode for wrapping. Between other characters, the nearest shared inline or paragraph mode controls the break. The same styles and source offsets apply when a rich draw continues on a later page
pre and pre-wrap preserve spaces, tabs and source newlines. pre wraps only at forced breaks. pre-wrap also wraps at Unicode line opportunities, with trailing preserved whitespace hanging at a soft break
break-spaces preserves spaces, tabs and source newlines. Each preserved space, tab and Unicode space separator other than the ordinary nonbreaking space can provide a wrap opportunity. Preserved whitespace counts towards the line width and can continue onto the next line or page
Preserved tabs use the paragraph's inherited or explicitly declared CSS tab-size. A unitless value multiplies the paragraph font's space advance and defaults to eight. Supported lengths use pt, px, in, cm, mm, em or ch. A zero size gives the tab no advance. Stops are measured from the paragraph content edge, with one extra stop when the next stop is less than half a digit advance away
A soft hyphen (U+00AD) has no visible text or advance until the layout chooses its break. The visible hyphen uses the original inline style and counts towards line width. A continuation starts after the source soft hyphen. A following hard break leaves it hidden
Each line computes its own centre or right alignment and common baseline; justified lines distribute spare width across actual word spaces after a soft wrap, whilst the final line and lines ended by br retain their natural spacing
The effective native para.lineHeight applies to every line and cannot reduce the line step below the text height; adjacent paragraph spacing is applied once around the complete paragraph
Inline font and colour overrides survive line fragmentation, and nested styles inside a hyperlink remain effective; each positioned hyperlink fragment retains its destination and creates its own native PDF link rectangle
HPDFXFAFlatten uses the supplied TXFAMeasureTextFunc for fitting, with bounded prefix probes for oversized words; when no measurer is supplied, its fallback uses one half-em advance per Unicode scalar
Version 2.1149.0 also uses this same paragraph plan for automatic rich draw dimensions, retaining styled line heights and paragraph spacing before the flow box is allocated. Unbounded natural width disables soft wrapping whilst preserving hard breaks; automatic dimensions still require a valid measurer
THotPDF.ApplyXFAAsAcroForm uses the native font measurer and preserves runtime changes through XDP save and reload, including independent text, colour and paragraph overrides on repeated instances
For complex-context text such as Thai, the line breaker uses dictionary opportunities from system ICU when available. These opportunities respect inline whitespace modes and grapheme boundaries across styles and continuation pages. Without ICU, the layout can wrap between grapheme clusters in complex-context text. Other text continues to use Unicode default line-break classes
Solid underline, overline and line-through can be combined on a rich draw using text-decoration or text-decoration-line. Both PDF output paths paint the lines in the run's text colour, relative to the rendered text baseline. Wrapped fragments draw their own decoration, and none clears inherited decoration for the run
For editable rich text fields in portable PDF output, see Automatic XFA creation. Interactive XFA canvas editing and other decoration styles are separate targets
Paragraph Geometry, Rich Text Property Overrides and ApplyXFAAsAcroForm