property CharacterMapError[Index: Integer]: Boolean; // read only
| Index | Zero-based character index on the current page, in the range 0 to CharacterCount - 1. |
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.
True and the current page has been parsed; otherwise it returns False.
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;