PDFium Component Docs

Properti CharacterMapError

Component: TPdf  ·  Unit: PDFium
Mengembalikan True ketika karakter pada indeks yang ditentukan tidak dapat dipetakan ke code point Unicode yang valid. Flag ini dilaporkan per karakter oleh extractor teks PDFium dan membantu pemanggil mengidentifikasi code point yang kemungkinan salah karena font asal tidak memiliki ToUnicode CMap atau vektor encoding yang dapat dipakai

Syntax

property CharacterMapError[Index: Integer]: Boolean; // read only

IndexZero-based character index on the current page, in the range 0 to CharacterCount - 1.

Description

CharacterMapError returns True when PDFium encountered an error mapping the character at the specified index to a Unicode code point. When this is True, the value returned by Character[Index] is unreliable and often falls back to a replacement character (#$FFFD) or to a passthrough of the underlying glyph identifier.

The flag is most commonly raised on PDFs produced by printer drivers and conversion tools that embed font subsets without a corresponding ToUnicode CMap, or with a CMap that does not cover the full glyph set. Scanned PDFs with embedded OCR text and PDFs that use custom encoding vectors are typical sources of map errors.

Callers that need to round-trip text from a PDF should filter or annotate CharacterMapError hits before treating them as searchable content. A cluster of consecutive map errors usually indicates an entire string run that should be re-extracted through OCR rather than via the text layer.

Remarks

Example

var
  I, BadCount: Integer;
begin
  BadCount := 0;
  for I := 0 to Pdf.CharacterCount - 1 do
    if Pdf.CharacterMapError[I] then
    begin
      Memo1.Lines.Add(Format('Map error at %d (charcode $%x)',
        [I, Pdf.Charcode[I]]));
      Inc(BadCount);
    end;
  Caption := Format('%d untranslatable characters on page', [BadCount]);
end;

See Also

Character, Charcode, CharacterGenerated, CharacterCount, Text