XFA Rich Text Paragraph Geometry
Rich text draw paragraphs place inline runs of different font sizes on a common PDF text baseline while retaining each run's effective font, size, colour, weight, posture and recognised CSS overrides
The layout engine offsets smaller run boxes within the line and sends the run-relative baseline through the baseline entry of the draw style channel; THotPDF emits that baseline directly and restores the page's prior TopTextPosition mode after each run
The distance between adjacent paragraphs uses the greater of the preceding paragraph's spaceBelow and the following paragraph's spaceAbove, including recognised inline CSS paragraph-margin overrides; empty paragraphs contribute no line or spacing
For example, a 30 pt line step followed by spaceBelow="4pt" and spaceAbove="3pt" advances the following paragraph by 34 pt
Paragraph lineHeight cannot reduce the line step below the height required by its text, and left, centre, right or justify alignment continues to use the effective paragraph margins and indentation
Native per-instance form overrides remain independent across repeated occurrences and persist through XDP save and reload before PDF production
These rules apply to every line in the rich text wrapping pipeline; complete widget rich text editing, additional CSS declarations and complete decoration geometry continue as separate rendering targets
Natural rich draw dimensions
Starting with Version 2.1149.0, a draw/value/exData node with omitted dimensions uses the same styled paragraph plan for intrinsic measurement and emission when a valid text measurer is supplied. Natural height includes complete line advances, collapsed inter-paragraph spacing and the last nonempty paragraph's trailing space, with the actual run boxes retained as a lower bound
The plan resolves the same effective form properties, per-run fonts, paragraph margins, indentation and native line height at the available width. Existing minimum and maximum constraints then govern the allocated box, so following flow starts after the allocated rich draw height
An unbounded natural-width request preserves paragraphs and explicit br breaks without soft wrapping or unused alignment padding. Once a width is allocated, height measurement uses the normal wrapping plan for that width
Explicit-box run emission and the existing plain-text measurement callback retain their prior behaviour. Missing measurers retain the existing automatic-size fallback, and intrinsic cache and operation limits still apply. Version 2.1150.0 adds the separate source-aware continuation behaviour below
The focused public flatten controls (Tests/XFA/GrowableRichDraw/IntrinsicExtent/Readme.en-us.md) retain the actual baseline and candidate geometry, including styled spacing, changed widths, min/max constraints, natural width and following-flow placement
Styled rich draw continuation
Starting with Version 2.1150.0, growable flowed draw/value/exData content can continue across content areas and pages when its Keep policy permits splitting and a valid font-aware measurement callback is available
Each accepted fragment retains its original Form and data node identity and consumes a source interval. The next area reflows the remaining styled source at that area's width; it does not crop the old line plan, duplicate the entire payload or flatten styled content into a plain-text override
Continuation consumes complete lines and preserves inherited styles and link targets. A resumed paragraph does not repeat its top margin or first-line indent, and its bottom margin is consumed only when that paragraph ends. Empty paragraphs preserve the existing no-line behaviour while their structural source units are still consumed
Keep probes, Keep resume and qualified last-page replay use the same rich planner and source coordinates. Fixed boxes, default intact content, explicitly intact content, missing measurement callbacks and ordinary plain fields retain their existing paths
The continuation acceptance (Tests/XFA/GrowableRichDraw/Continuation/README.en-us.md) includes actual two-width public layout, source-identity and budget controls, final ordinary/intrinsic protections, and real-font saved/reloaded PDF output with text and ink inside both content areas. The supplied single-face PDF profile verifies text and colour; callback style preservation does not imply that every consumer supplies every requested font face
Rich source coordinates
Rich intervals use zero-based half-open UTF-16 coordinates in the effective decoded source before whitespace collapse. Text contributes its original UTF-16 code units, including whitespace later collapsed by layout; each recognised br and paragraph end contributes one structural unit
These are not serialised XML offsets, emitted-text offsets or indices into SourceIdentity. For <p>A B</p><p>C</p>, the six units are A, space, B, paragraph end, C and paragraph end. For <p>A<br/>B</p>, the total is four units. A boundary must not split a UTF-16 surrogate pair or a CRLF pair
TXFAPositionedItem.HasRichTextRange selects RichSourceStart, RichSourceLength, RichSourceTotal and RichSourceIdentity instead of a plain TextOverride. Captured placements expose TXFALayoutTextRangeKind through TextRangeKind: xltrkPlainUTF16 retains the original plain-text meaning, while xltrkRichSourceUTF16 identifies rich source coordinates. Rebuild consumers of these public records against the new declarations
Source measurement helpers
Unit HPDFXFA exposes HPDFXFAHasRichDrawSource(Document, DrawNode, DataNode) and HPDFXFATryMeasureRichDrawSource(Document, DrawNode, DataNode, MaxWidth, MeasureText, SourceStart, Source, Charge). The latter measures the remaining effective rich source from an absolute cursor with the shared planner; the optional TXFARichSourceCharge method callback receives work charges
| TXFARichSourceLayout field | Meaning |
|---|---|
SourceStart | Requested absolute source cursor |
SourceLength | Total source length, including the skipped prefix |
SourceIdentity | Opaque equality token for effective source, styles and layout properties; not a persistent interchange format |
Extent | Remaining content extent at the supplied width |
Lines | Complete TXFARichSourceLine boundaries, each carrying absolute SourceEnd and cumulative Height from the requested start |
PXFARichSourceLayout is the corresponding pointer type. Consume measurement results only after a successful call; invalid boundaries, metrics and exhausted budgets can raise an XFA error
Rich continuation retains bounds of 1,048,576 UTF-16 source units, 32,768 recorded lines and 1,024 fragments, with source and line work also charged to the layout operation budget. This delivery does not expand underlying shaping, CSS, script or font-face support beyond the existing planner and selected consumer