property CharacterMapError[Index: Integer]: Boolean; // read only
| Index | 현재 page의 0 기반 character index입니다. 범위는 0 .. CharacterCount - 1입니다 |
CharacterMapError는 PDFium이 지정한 인덱스의 character를 Unicode code point로 매핑하는 동안 오류를 만났을 때 True를 반환합니다. 이 값이 True이면 Character[Index]가 돌려주는 값은 신뢰할 수 없으며, 보통 대체 character(#$FFFD)로 떨어지거나 기반 glyph identifier를 그대로 통과시킵니다
이 flag는 보통 대응하는 ToUnicode CMap이 없거나 전체 glyph set을 덮지 않는 CMap과 함께 font subset을 포함한 PDF를 만든 printer driver나 conversion tool에서 가장 자주 나타납니다. embedded OCR text가 있는 scanned PDF와 custom encoding vector를 쓰는 PDF도 일반적인 map error 원인입니다
PDF의 text를 round-trip해야 하는 caller는 검색 가능한 content로 취급하기 전에 CharacterMapError hit를 걸러내거나 주석을 달아야 합니다. 연속된 map error 묶음은 보통 text layer가 아니라 OCR로 다시 추출해야 할 전체 string run을 뜻합니다
True이고 현재 page가 parse되었을 때만 의미가 있으며, 그렇지 않으면 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;