GetTextBlockCharContentLocation

Text, Extraction, Content streams, Diagnostics

Description

Returns the stable content-stream location and encoded source-byte range associated with one extracted character

Syntax

Delphi

Function TPDFlib.GetTextBlockCharContentLocation(TextBlockListID, Index,
  CharIndex: Integer; Out ContentLayer, StreamObjectNumber,
  StreamGeneration, InstructionIndex, OperandIndex, ArrayElementIndex,
  SourceByteOffset, SourceByteLength, Flags: Integer): Integer;

Parameters

TextBlockListIDHandle returned by ExtractPageTextBlocks
Index1-based text block index
CharIndex1-based UTF-16 code-unit position inside the block text
ContentLayer1-based page /Contents layer, or 0 for nested content
StreamObjectNumberObject number of the containing stream, or 0 for a direct stream
StreamGenerationGeneration number of the containing stream
InstructionIndex0-based instruction index in the decoded content program
OperandIndex0-based text-string operand index
ArrayElementIndex0-based TJ array element, or -1 for a direct string operand
SourceByteOffset0-based offset in the decoded string value, or -1 when no safely addressable range exists
SourceByteLengthNumber of encoded source bytes for the source glyph, or 0 when no safely addressable range exists
FlagsBitwise content-location flags described below

Return values

1A location record was returned, including synthetic or read-only records
0The handle, block index or character index is invalid

Flags

PDF_TEXT_CHAR_CONTENT_LOCATION_VALIDThe byte range identifies a content string, subject to any read-only flags
PDF_TEXT_CHAR_CONTENT_LOCATION_GENERATEDThe character was generated during layout and has no source bytes
PDF_TEXT_CHAR_CONTENT_LOCATION_LIGATUREMultiple extracted UTF-16 positions share one source glyph range
PDF_TEXT_CHAR_CONTENT_LOCATION_ACTUALTEXTThe character came from an /ActualText replacement and is read-only
PDF_TEXT_CHAR_CONTENT_LOCATION_NESTEDThe character came from nested Form content and is read-only
PDF_TEXT_CHAR_CONTENT_LOCATION_CROSS_LAYERThe operand and text-showing operator cross page content layers and are read-only
PDF_TEXT_CHAR_CONTENT_LOCATION_TRANSCODEDThe source string was transcoded before font mapping, so decoded offsets cannot address its original bytes safely

Remarks

Offsets address decoded font-encoded string bytes rather than Unicode text

Supplementary characters and ligature expansions may return the same source range for more than one UTF-16 position

Use ReplaceTextBlockCharSourceBytes only when the valid flag is set and none of the read-only flags is present

Location lookup uses extraction-time spans and does not reparse page content