Commit 36e38ef
feat(pdf): docling-parse migration phase 1 — char-extraction parity + tooling
Groundwork for porting docling-parse's text reconstruction (the path to higher
PDF conformance). Two pieces:
- Lam-alef ligature order: pdfium splits the Arabic lam-alef ligature into two
chars at the *same* x in visual order (`alef-variant, lam`); docling-parse and
logical order are `lam, alef-variant`. Reorder same-x ligature pairs at the
glyph level. The shared-x test reliably distinguishes a real ligature from a
genuine `alef + lam` sequence (article `ال`, `فعالة`) whose glyphs sit at
different x — unlike the earlier ambiguous mid-word heuristic.
- Debug tooling: `pdfium_backend::debug_glyphs` + `examples/dump_chars` dump the
raw pdfium char stream (codepoint + x) to diff against docling-parse's char
cells; `pdfium_backend` is now `pub` for inspection.
Verified char-extraction parity against docling-parse: both emit chars in
content-stream order (visual for RTL), and with the ligature fix the lam-alef
order matches. The EXACT 3 stay exact; Arabic-only, no other regressions.
Next (phase 2): port `cells.h`'s 3-pass line contraction (corner-distance
adjacency + merge_with space insertion, LTR/RTL/LTR-reverse) to replace the
ad-hoc reconstruction — targets multi_page (run-boundary colons) and the RTL PDFs.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 7bf2caa commit 36e38ef
3 files changed
Lines changed: 57 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
240 | 268 | | |
241 | 269 | | |
242 | 270 | | |
| |||
270 | 298 | | |
271 | 299 | | |
272 | 300 | | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
273 | 318 | | |
274 | 319 | | |
275 | 320 | | |
| |||
0 commit comments