Since 3.267.0, the returned TPdfReflowDocument also provides WriteHtml(Writer: TPdfReportWriter; MaxDepth: Integer = 64) for serialisation directly through output/item limits, document node/text limits and a configurable depth bound
The legacy ToHtml string method retains its existing behaviour; use bounded report writing when intermediate HTML construction must obey the selected limits
function BuildReflowDocument(
const Options: TPdfReflowOptions;
const CancellationToken: IPdfCancellationToken = nil): TPdfReflowDocument;
BuildReflowDocument reads every selected page through GetStructuredText, prefers Tagged PDF semantics, and falls back to physical-layout inference when structure is absent
The returned TPdfReflowDocument.Nodes array is a stable pre-order tree with ParentIndex and Depth, avoiding recursive ownership whilst preserving page, heading, paragraph, list, figure, caption, table, row, and cell relationships
Each TPdfReflowNode carries its page, text, language, semantic source, bounds, heading level, the table coordinates RowIndex and ColumnIndex with their spans, the IsHeader state, and confidence where applicable
TPdfReflowOptions selects the page window and output gates; DetectTables enables table detection with the nested TableOptions budget record, and the resulting TPdfReflowDocument exposes the detected TableCount alongside its node tree
Detected table text replaces overlapping paragraph blocks so the reflowed result does not duplicate table content
TPdfReflowDocument.ToHtml emits semantic h1 through h6, p, ul, li, figure, figcaption, table, th, and td elements
Text and attribute values are always escaped, row and column spans are retained, and optional responsive CSS requires no script or external resource
FullDocument, IncludeCss, IncludePageSections, IncludeGeometry, and PreserveLineBreaks control serialisation without reparsing the PDF
FirstPage and LastPage are one-based, with zero selecting the document boundaryMaxCharacters, MaxNodes, and the nested table budgets fail closed before unbounded outputvar
Options: TPdfReflowOptions;
Document: TPdfReflowDocument;
begin
Options := TPdfReflowOptions.Default;
Options.IncludeGeometry := True;
Document := Pdf1.BuildReflowDocument(Options);
Memo1.Text := Document.ToHtml;
end;