PDFium Delphi Component Docs

GetStructuredText method

Component: TPdf  ·  Unit: PDFium
Extracts the current page into reusable blocks, lines and styled spans with source indices and page geometry

Syntax

function GetStructuredText(
  const Options: TPdfStructuredTextOptions): TPdfStructuredTextPage;

Description

GetStructuredText reads Unicode scalars, character boxes, font size, font weight, font name, angle and text-object identity through PDFium's native text APIs

Characters become styled spans, spans become physical lines, horizontally related lines become blocks, and block text is joined into the page-level Text field

Every native scalar is preserved as UTF-16, including supplementary-plane characters represented by surrogate pairs

Options

Result hierarchy

RecordKey data
TPdfStructuredTextPagePageNumber, Width and Height, character and failure counts, Source, combined Text, and Blocks
TPdfStructuredTextBlockBounds, text, structure kind, heading level, language, source, structure-element index, and Lines, the array of TPdfStructuredTextLine records clustered into the block; block Text joins those lines and block Bounds is the union of their bounds
TPdfStructuredTextLineBounds, combined text, and styled spans
TPdfStructuredTextSpanText, Bounds, the SourceStartIndex and SourceCharacterCount range, FontName, FontSize, FontWeight, and Angle

Semantics and geometry

Performance

Physical ordering uses O(n log n) character sorting, geometrically growing line and span buffers, buffered UTF-16 construction, and adjacent non-null text-object font caching

Set IncludeFontInfo or IncludeSemantics to False when those enrichment layers are unnecessary

Example

var
  Options: TPdfStructuredTextOptions;
  Page: TPdfStructuredTextPage;
begin
  Options := TPdfStructuredTextOptions.Default;
  Options.MaxCharacters := 250000;
  Page := Pdf1.GetStructuredText(Options);
  Memo1.Text := Page.Text;
end;

See Also

TPdf, Text, ExtractTables, BuildReflowDocument, ApplyOcrSearchLayer, StructureElements