Trace changes in the text layer of two exports of the same PDF document.
node .\dist\pdftextguard-v0.0.8.cjs --version
# 同一内容用不同字体子集绘制。预期 0,300 个字形成功对齐。
node .\dist\pdftextguard-v0.0.8.cjs check .\verification\fixtures\pdfkit-0.18.0-300.pdf .\verification\fixtures\subset-reordered.pdf
# 文件仍能正常显示,但首个字符的复制结果从 ! 变成 Z。预期 1。
node .\dist\pdftextguard-v0.0.8.cjs check .\verification\fixtures\pdfkit-0.18.0-300.pdf .\verification\fixtures\wrong-unicode.pdf --json
# 已确认只有绘制顺序变化时,按唯一位置检查映射。这个例子仍会报告一处回归。
node .\dist\pdftextguard-v0.0.8.cjs check .\verification\fixtures\pdfkit-0.18.0-300.pdf .\verification\fixtures\draws-reordered-wrong.pdf --json --align-by-position| 退出码 | JSON outcome | CI 含义 |
|---|---|---|
| 0 | pass | 覆盖范围内的用字成功对齐,未发现回归。 |
| 1 | regression | 对齐成立,候选出现已用映射变化、缺失或 CMap 语法问题。 |
| 2 | inconclusive | 覆盖不完整,包括基线无可靠映射、PDF 结构错误、超出范围及无法可靠对齐。 |
| 场景 | 观察结果 |
|---|---|
| PDFKit #1659 的两个真实版本 | 0.17.2 用 300 个不同字形,CMap 声明 1 个范围、实际 2 个。0.18.0 是 2/2。两份像素相同,PDFium 提取不同。200 个不同字形和重复 300 次 A 的对照正常。 |
| 同源导出更换实际字体子集 | 两份嵌入 FontFile2 散列不同,首个字形 GID 从 1 变为 300。像素和复制文本均相同,检查器对齐 300 个字形、零误报。 |
| 换子集并控制性改错一个映射 | 像素相同,PDFium 的首字符从 ! 变为 Z。检查器报告恰好一处变化,双方内容流操作和 CMap 字节位置由 pypdf 独立核对。 |
| 范围外和保守对齐 | 重叠字形、位置变动、ActualText 及加密输入均返回无法确认。更换对象编号和子集前缀、未用映射变化和显式 CID 到 GID 重编码均通过。 |
| 嵌套表单、旋转和绘制重排 | 独立验证确认测试对中的像素一致,并复核两层表单调用的字节位置。保守模式拒绝画序变化,选择按位置后可以发现同位置的错映射。 |
| PDFBox 3.0.4 的两种真实保存方式 | PDFium 渲染与提取一致,PDFTextGuard 对齐并检查 38 次绘制。受控变体只把 ! 映射为 Z,像素保持一致,报告定位到一条规则。 |
moon add WeiR-h/pdftextguard@0.0.8.\scripts\build.ps1 -Test
node .\verification\smoke.cjsnpm ci --prefix .\verification\pdfkit --ignore-scripts
node .\verification\pdfkit\generate.cjs
python .\verification\mutate_fixtures.py
python .\verification\geometry_fixtures.py
node .\verification\smoke.cjs
python .\verification\verify_reference.pypub struct CMapSpan {
operator : String
decoded_offset : Int
decoded_end : Int
value_offset : Int?
range_index : Int?
} derive(ToJson)pub struct Diagnostic {
code : String
side : String
message : String
page : Int?
stream : StreamSite?
baseline : UseSite?
candidate : UseSite?
cmap : CMapDiagnostic?
} derive(ToJson)pub struct Report {
schema_version : Int
tool_version : String
outcome : String
exit_code : Int
coverage : String
baseline_pages : Int
candidate_pages : Int
baseline_glyphs : Int
candidate_glyphs : Int
aligned_glyphs : Int
position_aligned_pages : Int
compared_glyphs : Int
mismatched_occurrences : Int
diagnostics_omitted : Int
diagnostics : Array[Diagnostic]
} derive(ToJson)pub struct UseSite {
page : Int
content_object : ObjectRef?
stream_index : Int
operator : String
operator_offset : Int
string_offset : Int
byte_index : Int
font_resource : String
font_object : ObjectRef?
descendant_object : ObjectRef?
font_file_object : ObjectRef?
cmap_object : ObjectRef?
code : String
cid : Int
gid : Int
origin_x : Double
origin_y : Double
display_origin_x : Double?
display_origin_y : Double?
unicode : Array[String]?
rule : CMapSpan?
form_path : Array[FormCall]?
} derive(ToJson)