Native rich grid and flex sizing

The structured AcroForm appearance engine sizes grid tracks and flex boxes from supplied XHTML and explicit font families, with the same transactional field update, workspace admission and cancellation controls as other native rich-text layout

Use THPDFHeadlessDocument.SetRichTextFieldXHTMLWithFamilies for a loaded field or HPDFBuildHeadlessRichLayoutAppearance for a standalone appearance bundle; their public signatures are unchanged

Grid track lists

Set display:grid and provide grid-template-columns as a space-separated list of definite lengths, nonnegative fr factors, minmax(minimum, maximum) entries or integer repeat(count, list) entries

Definite lengths use the existing supported units, including percentages resolved against the available content width; a minmax() minimum must be a definite nonnegative length and its maximum must be a definite length or an fr factor

The engine subtracts gaps and minimum sizes, grows finite maximum tracks within their limits, then distributes fractional space while preserving each minimum; fractional factors whose sum is below one can leave unused space

A finite maximum below its minimum is normalized to the minimum; minimum sizes that exceed the available width remain visible as overflow rather than being silently reduced

repeat() expands a positive integer count and a nonempty track list within MaxColumns; nested repeats, automatic repeat counts and intrinsic track keywords are outside this profile

Grid items use stable order-modified source order for placement and painting; flex-direction does not select the grid placement axis, while source XHTML and plain field value generation retain DOM order

<body xmlns="http://www.w3.org/1999/xhtml">
  <div style="display:grid; width:300pt; gap:10pt;
              grid-template-columns:60pt minmax(40pt,1fr) 2fr">
    <div style="height:20pt; background-color:#ff0000">A</div>
    <div style="height:20pt; background-color:#0000ff">B</div>
    <div style="height:20pt; background-color:#008000">C</div>
  </div>
</body>

Grid item placement and row tracks

Place grid items with numeric grid-column-start, grid-column-end, grid-row-start and grid-row-end, or their grid-column and grid-row shorthands; positive lines count from the start and negative lines count from the explicit grid end

Use span or span N for a bounded positive span; reversed definite lines are normalized, equal lines discard the end, and two spans discard the end span

Numeric and named placement may extend before or after the explicit grid; negative numeric lines remain relative to the explicit end, and leading implicit tracks preserve the explicit line origin

grid-auto-flow:row and column use sparse placement with a forward cursor; either axis accepts dense to fill earlier holes without changing DOM ownership or stored XHTML

Define rows with grid-template-rows and a repeating implicit pattern with grid-auto-rows; supported row tracks include definite nonnegative lengths, nonnegative fractional factors, auto, bounded integer repeats and minmax() with fixed or automatic minima and fixed, automatic or fractional maxima

Automatic item contributions establish row minima and growth limits; definite free space grows finite limits before fractional tracks, while minimum violations freeze constrained fractional tracks and fixed tracks preserve overflow

Definite row percentages use the definite container content height; indefinite percentage row tracks and general browser minimum-content column sizing remain outside this profile

gap accepts one or two values and expands into independently cascaded row-gap and column-gap; percentage column gaps use the final content width after specified, constrained or forced sizing, excluding padding and borders

For auto-height grids, percentage row gaps contribute zero while measuring intrinsic tracks, then resolve against the final content height after minimum and maximum height constraints; the resulting gutter can overflow without recursively enlarging intrinsic height

<div style="display:grid; grid-template-columns:100pt 100pt;
            grid-template-rows:20pt 30pt; gap:6pt 10pt">
  <div style="grid-column:1; grid-row:1 / span 2; height:56pt">A</div>
  <div style="grid-column:2; grid-row:1; height:20pt">B</div>
  <div style="height:30pt">C</div>
</div>

Named lines, implicit columns and column flow

Track lists accept bracketed line names before and after tracks and inside bounded integer repeats; names at a repeat boundary join the same physical line, and repeated names on one line identify one occurrence

Grid line names are case-sensitive CSS custom identifiers with supported simple and hexadecimal escapes, including complete supplementary codepoints; decoded whitespace belongs to the identifier and is not trimmed into a reserved keyword

Placement accepts named lines, nonzero named occurrence indices, and positive named spans combined with counts; positive and negative occurrences search from the corresponding explicit-grid edge, while a named span counts implicit assumed names only beyond the explicit grid in its search direction

Leading and trailing implicit tracks retain the explicit origin used by numeric and named lines; negative numeric indices continue to count from the explicit grid end after implicit tracks are added

grid-auto-columns supplies a repeated implicit pattern with the supported definite, automatic, fractional and bounded minmax sizing forms; patterns apply beyond either explicit edge without changing the declared column track sizes

grid-auto-flow:column fills the row axis before advancing columns, and accepts dense for hole filling; items locked to a row use the same placement step order and sparse cursor rules with the two axes exchanged

An empty grid without explicit rows creates no implicit rows and has zero logical content height, so subsequent blocks retain their exact flow position; a positive internal PDF Form bounding box does not add logical height

Names, missing occurrences, implicit extents and both placement axes share the original operation, cancellation, cell, column and workspace limits, including checked integer bounds before allocation

Flex axes and constrained sizes

Set display:flex and select flex-direction:row, row-reverse, column or column-reverse; reverse placement preserves each child's text and glyph order

Child flex-basis, flex-grow and flex-shrink control the main size, constrained by min-width and max-width for rows or min-height and max-height for columns

A definite basis takes priority over the child's main dimension; otherwise a definite dimension or bounded content measurement supplies the basis

Explicit dimensions, constraints and bases are content sizes; padding and borders are added to obtain outer sizes, and margins and gaps consume separate space

Zero is a specified size, not an absent declaration; fixed padding and borders remain present when a content dimension is zero

Positive free space uses grow factors, while shrinking uses each shrink factor multiplied by its content basis; minimum and maximum violations freeze constrained items before the remaining space is redistributed

A percentage column basis resolves against a definite container content height; an indefinite main height uses content measurement instead of resolving the percentage against the available width

flex-wrap:wrap groups row children using their constrained outer bases and lays out each row independently; row height includes vertical margins, with the configured gap between rows

For flex-wrap:wrap, column and column-reverse containers collect separate flex lines using constrained outer main sizes, margins and row gaps; each line resolves grow, shrink and main-axis alignment independently

A specified or stretch-assigned content height supplies the line collection limit; an auto-height column stays single-line unless max-height provides a finite bound, while min-height affects the final main size after collection

Column gaps separate line cross boxes; normal content alignment stretches those line boxes across available width, then align-items and align-self apply each item's explicit or constrained cross size

Cyclic percentage flex main gaps resolve to zero for indefinite height; padding and borders are excluded from the definite content-height basis

An unwrapped row without explicit child flex sizing, definite width or width constraints retains the previous equal-share profile

Shorthand, visual order and alignment

The flex shorthand accepts none, auto, initial, one or two nonnegative factors, a basis alone, or factors followed by a basis, including a unitless third zero

Shorthand expansion participates in declaration order and important priority through the three actual longhands; an invalid shorthand leaves previous valid declarations intact

Integer order sorts flex children stably for placement and painting; equal values retain source order, and source XHTML, node ownership and plain field value generation remain in DOM order

justify-content supports flex-start, flex-end, center, space-between, space-around and space-evenly

For negative free space, space-between falls back to the start, while space-around and space-evenly use centered overflow; gaps remain separate from distributed space

align-items and align-self support flex-start, flex-end, center and stretch; the default flex cross alignment is stretch

An explicit cross size, including zero, is preserved; stretch applies the child's finite minimum and maximum cross constraints

Flex line content alignment

flex-wrap:wrap-reverse collects the same order-modified lines as wrap and swaps cross-start with cross-end; row and column main-axis reversal remains independent, and each child retains its logical text and glyph order

align-content accepts bare normal, stretch, start, end, flex-start, flex-end, center, space-between, space-around and space-evenly

In this horizontal writing-mode profile, start and end refer to physical top/bottom for rows or left/right for columns; flex-start and flex-end follow the reversed flex cross sides

Normal behaves as stretch: positive cross free space grows each line equally, then each item uses its explicit cross size or constrained align-self stretch; lines are never shrunk by align-content

Between adds free space only to inter-line gutters; around gives each outer edge half a distributed gutter, while evenly gives the edges and inter-line gutters equal extra space; declared gaps remain separate

Negative distributed free space uses safe cross-start without shrinking lines, while explicit center permits symmetric overflow; flex-end and end retain their specified side semantics

Nowrap is a single-line container and ignores align-content; a wrapping container with only one collected line still applies it, with between falling back to cross-start and around/evenly centering positive free space

Row line alignment uses the final content height after explicit or assigned sizing and minimum/maximum constraints; auto-height intrinsic measurement is not enlarged recursively by alignment, but a final minimum height can provide stretch or positional free space

Column line alignment uses the actual content width; nested intrinsic column measurement returns natural line contributions before any container free-space distribution

Measured appearances are reused only when their cross size and planned destination object IDs remain valid; required stretch or object-count changes rebuild with the same cumulative workspace and cancellation account

Grid content and item alignment

Grid justify-content and align-content accept bare normal, stretch, start, end, flex-start, flex-end, center, space-between, space-around and space-evenly; justify-content also accepts physical left and right

Inline alignment uses physical left/right and block alignment uses top/bottom; flex-start and flex-end are aliases of the corresponding Grid start and end, independent of flex-direction and flex-wrap

Content distribution uses the final constrained content box after track sizing and cyclic gap resolution; declared gaps remain separate from distributed space, and distributed alignment with negative free space falls back to the start while explicit center and end can preserve overflow

Normal and stretch distribute positive block free space only among eligible rows with automatic maximum sizing and no fractional factor; definite, finite-maximum and fractional rows keep their sizes, and the supported definite/minmax/fr columns are not stretched

justify-items, align-items, justify-self and align-self accept bare normal, stretch, start, end, flex-start, flex-end and center; the inline justify properties additionally accept left and right, and self properties accept auto to use the corresponding container item alignment

Normal stretches ordinary items with an automatic dimension while replaced images retain intrinsic-ratio start placement; explicit dimensions, including zero, remain specified and stretch respects finite minimum and maximum content sizes

Item alignment uses the complete spanned area including internal gutters, subtracts margins separately and measures non-stretched automatic widths before placement; nested block, table and flex content contributes bounded intrinsic widths

These six longhands keep an independent valid cascade with declaration order and important priority; an unsupported value leaves the previous valid Grid declaration intact

Inner rich forms retain paint bounds for visible text, borders and child overflow, while the outer Widget form retains its clipping and rotation profile; logical text metrics and stored DOM order remain unchanged

The two standalone layout-only helpers are HPDFComposeHeadlessRichOverflowAppearanceWithWorkspace and HPDFBuildHeadlessRichTextFamilyLayoutAppearanceWithWorkspace

Nested intrinsic measurement

Bounded intrinsic width measurement includes nested block decorations and uses the widest separate block line; inline runs retain native font measurement, and explicit line breaks end a measured line

Nested row flex contributions include their bases, constrained flexibility, margins and gaps; unwrapped column cross measurement uses the largest decorated child contribution, while wrapped columns include the measured line widths and cross gaps

Content minimum and maximum constraints apply before padding and borders; child margins belong to the parent's contribution rather than the child's returned border-box width

Budgets and retained field state

Track expansion shares MaxColumns, child collection shares MaxCells, and parsing, sizing iterations, ordering, intrinsic measurement and placement share MaxOperations and the caller's cancellation token

Recursive intrinsic measurement retains its 64-level and aggregate 4096-run bounds, and temporary planning arrays use admitted workspace capacity

Stretch can require a second build; temporary measurement and rebuilding remain cumulatively charged to the same workspace admission, and a failed admission or cancellation does not publish a partial appearance bundle

The document entry point retains the original XHTML in /RV, updates the plain value and Widget appearance together, and preserves loaded state on a rejected transaction so the same handle can retry with valid options

This finite form-appearance profile does not implement general browser layout, grid-template-areas, indefinite percentage row tracks, RTL Grid track reversal, alignment shorthands, baseline alignment, safe/unsafe prefixes, flex-flow shorthand, auto margins, vertical writing modes, border-box sizing, general cyclic percentage sizing or browser automatic minimum-content sizing

See THPDFHeadlessRichLayoutOptions for option defaults and native rich-text layout for resource and field-state rules