PDFium Component Docs

ιδιότητα CharacterMapError

Component: TPdf  ·  Unit: PDFium
Επιστρέφει True όταν ο χαρακτήρας στο δοσμένο ευρετήριο δεν μπόρεσε να αντιστοιχιστεί σε έγκυρο Unicode code point Το flag αναφέρεται ανά χαρακτήρα από τον εξαγωγέα κειμένου του PDFium και επιτρέπει στους καλούντες να εντοπίζουν code points που πιθανότατα είναι λανθασμένα επειδή η αρχική γραμματοσειρά δεν διαθέτει χρησιμοποιήσιμο ToUnicode CMap ή encoding vector

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