PDFium Component Docs

CharacterMapError property

Component: TPdf  ·  Unit: PDFium
وقتی نویسهٔ موجود در index مشخص‌شده نتوانسته باشد به یک Unicode code point معتبر map شود، True برمی‌گرداند. این flag را text extractorِ PDFium برای هر نویسه گزارش می‌کند و به caller اجازه می‌دهد code pointهایی را که احتمالاً نادرست‌اند تشخیص دهد، چون font مبدأ یک 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