PDFium Delphi Component Docs

GetTextInReadingOrder method

Component: TPdf  ·  Unit: PDFium
Extract the text of the current page either in content-stream order or sorted into natural reading order

Syntax

function GetTextInReadingOrder(Order: TPdfReadingOrder): WString;

OrderTPdfReadingOrder. roContentOrder follows the raw content stream, the same sequence iterating Character produces. roPhysicalLayout sorts characters by position, top to bottom and left to right
ResultWString. The page text in the requested order, empty when the page holds no text

Description

A content stream may draw text in any sequence - a generator can emit a footer before the body, or a column right to left. Content order preserves what the file says; physical layout reconstructs what a reader sees

Physical layout sorts on the centre of each character, descending by vertical position and ascending by horizontal position, so lines come out top to bottom and characters left to right within a line

For structure-driven order rather than geometry, a tagged document is better served by GetStructuredText or DocumentReadingUnits, which follow the declared reading order instead of inferring one

See Also

Text, GetStructuredText, DocumentReadingUnits, BuildReflowDocument