PDFium Delphi Component Docs

BuildReflowDocument method

Component: TPdf  ·  Unit: PDFium
Builds a bounded semantic reading model for responsive HTML, mobile reading, accessibility, and indexing

Syntax

function BuildReflowDocument(
  const Options: TPdfReflowOptions;
  const CancellationToken: IPdfCancellationToken = nil): TPdfReflowDocument;

Description

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

HTML output

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

Ranges and budgets

Example

var
  Options: TPdfReflowOptions;
  Document: TPdfReflowDocument;
begin
  Options := TPdfReflowOptions.Default;
  Options.IncludeGeometry := True;
  Document := Pdf1.BuildReflowDocument(Options);
  Memo1.Text := Document.ToHtml;
end;

See Also

GetStructuredText, ExtractTables, ReadableContent