PDFium Delphi Component Docs

TextIndexToCharacterIndex method

Component: TPdf  ·  Unit: PDFium
Map an offset in the extracted text back to the character that produced it

Syntax

function TextIndexToCharacterIndex(Index: Integer): Integer;

IndexInteger. Zero-based offset within the string returned by Text
ResultInteger. Zero-based character index on the current page, or -1 when no character corresponds to that offset

Description

The inverse of CharacterIndexToTextIndex. Once a caller has found something in the extracted string, this locates the character behind it, which is the index every geometric query takes

With the character index in hand, CharacterRectangle gives the box to highlight and CharacterInfo gives colour, font, and matrix

A result of -1 means the offset does not map back to a character on the page

See Also

CharacterIndexToTextIndex, Text, CharacterRectangle, CharacterInfo