Bug Description
The table cell text builder inserts spaces inside words. The flow text merger joins the same glyphs correctly, so cell text and page text disagree.
cell_span_separator emits a space when the gap between spans exceeds font_size * 0.15. The flow merger decides from per-glyph advance evidence, which the cell builder never sees.
Steps to Reproduce
- Fetch
issue7454.pdf from the pdf.js test corpus.
- Extract page 0 both ways:
let doc = PdfDocument::open("issue7454.pdf")?;
let spans = doc.extract_spans(0)?; // "Crédit < 21 500 euros" as one span
let tables = doc.extract_tables(0)?; // the same glyphs as a cell
Expected Behavior
Cell text matches flow text: Crédit < 21 500 euros.
Actual Behavior
The cell reads Cré d it < 21 500 euros. At 9 pt the threshold is 1.35 pt. The intra-word gaps are 2.04 pt and the legitimate space before < is 1.92 pt, so no constant separates them. Threshold tuning cannot fix this, and the function has already been retuned once after a regression.
Additional Notes
Fix direction: give the cell builder the flow merger's advance evidence, or have it consume flow-merged spans. This also removes a duplicate-emission case downstream: when cell text is split where flow text is merged, budget matching cannot pair them and both surfaces emit.
One caution. Teaching the budget matcher to consume concatenations of split cell tokens was evaluated and rejected. It creates a new deletion path and reintroduces order-dependent nondeterminism. Fix the spacing, not the matcher.
Related work, checked before filing: distinct from #1016 (there the span and word layer itself is corrupted by bad glyph advances for CID subset fonts; here extract_spans is correct and only the cell builder disagrees) and from #975 (adjacent columns merged in strict table detection: table topology, not in-cell spacing). Cite both as related when filing.
Bug Description
The table cell text builder inserts spaces inside words. The flow text merger joins the same glyphs correctly, so cell text and page text disagree.
cell_span_separatoremits a space when the gap between spans exceedsfont_size * 0.15. The flow merger decides from per-glyph advance evidence, which the cell builder never sees.Steps to Reproduce
issue7454.pdffrom the pdf.js test corpus.Expected Behavior
Cell text matches flow text:
Crédit < 21 500 euros.Actual Behavior
The cell reads
Cré d it < 21 500 euros. At 9 pt the threshold is 1.35 pt. The intra-word gaps are 2.04 pt and the legitimate space before<is 1.92 pt, so no constant separates them. Threshold tuning cannot fix this, and the function has already been retuned once after a regression.Additional Notes
Fix direction: give the cell builder the flow merger's advance evidence, or have it consume flow-merged spans. This also removes a duplicate-emission case downstream: when cell text is split where flow text is merged, budget matching cannot pair them and both surfaces emit.
One caution. Teaching the budget matcher to consume concatenations of split cell tokens was evaluated and rejected. It creates a new deletion path and reintroduces order-dependent nondeterminism. Fix the spacing, not the matcher.
Related work, checked before filing: distinct from #1016 (there the span and word layer itself is corrupted by bad glyph advances for CID subset fonts; here
extract_spansis correct and only the cell builder disagrees) and from #975 (adjacent columns merged in strict table detection: table topology, not in-cell spacing). Cite both as related when filing.