property CharacterGenerated[Index: Integer]: Boolean; // read only
| Index | 当前页面上从零开始的字符索引,范围为 0 到 CharacterCount - 1 |
CharacterGenerated 当指定索引处的字符由 PDFium 在内部生成而不是存在于原始内容流中时,返回 True。典型示例包括:连字分解(将 fi 连字字形拆分为 f + i)、PDFium 在视觉上分隔的相邻文本运行之间插入的尾随空格,以及在每个视觉行末尾注入的换行字符
生成的字符在页面内容流中没有自己的绘制,因此它们的边界框派生自相邻字形。如果需要像素精确的命中测试,请谨慎对待它们在页面上的位置;它们的 CharacterRectangle 可能塌缩为零宽度或零高度区域
对于诸如精确逐字提取(数字签名、文本哈希工作流、与页面内容流的 ASCII 真值比较)之类的任务,请先过滤掉生成的字符。对于常规文本搜索和剪贴板复制,使用该标志纯粹是信息性的 — PDFium 已经插入了这些字符,因为用户期望它们存在
True 命中;不要假设生成的字符总是不可见字形
// Build a verbatim string that contains only characters from the content stream
var
I: Integer;
S: WString;
begin
S := '';
for I := 0 to Pdf.CharacterCount - 1 do
if not Pdf.CharacterGenerated[I] then
S := S + Pdf.Character[I];
Memo1.Text := S;
end;