The row-keyed JSON point in the thread is the right output shape — and the question underneath it (infer the key or let users pass one) has a checkable answer: infer from a column whose values are unique and stable across two consecutive issues, and fall back to a user-supplied list when no column qualifies. The test that decides is running the diff on two real consecutive issues and counting false 'changed' rows — if the inferred key produces phantom changes, it's not a key.
Three failure modes your sample set needs to cover, from the benchmark I run against PDF-to-Markdown tools:
Rows split across a page break — the row-count assertion has to run per table, not per page, or the split row counts as a deletion plus an addition in the diff.
Repeated headers mid-table — dedupe must be source-preserving (a merged-table thread this week had exactly this: row B losing its page-8 citation after a header dedupe).
A scanned or 90-degree rotated page inside an otherwise digital report — per-page char-count floor before diffing, or the diff reports a whole page of 'deletions' that are really an extraction failure. On my fixture set a 90-degree page goes from recall 0.00 to 1.00 with detect_vertical=True — the kind of thing a diff can't see.
On samples: I have an 11-fixture benchmark set (rotated pages, scanned 3-pager, multi-page tables, merged headers) with per-page expected outputs — happy to share the fixture PDFs if you want them as your five. What format would be most useful, the raw PDFs or the per-page expected row counts alongside?
That 3-point failure checklist is gold — especially #3 (a rotated or scanned page silently triggering phantom row deletions in a diff unless gated by a per-page char-count floor).
We would genuinely love to test against your 11-fixture set. Both the raw PDFs AND the per-page expected row counts would be hugely valuable so we can wire them directly into our automated regression benchmark and measure recall honestly (and fix split-row page breaks + source-preserving header dedupe + rotated-page detection where we fall short).
Feel free to drop a repo link or attachment here or on https://github.com/stqnbapxao-source/structmint-b2b-automation-kit/issues/1 — happy to share back the exact per-fixture pass/fail numbers once we run it!
Thanks — happy to share the set, with one honest caveat about what it actually is.
The raw PDFs are public here: github.com/kamalmosadegh/pdf-slice... — 16 files. The ones most useful for your regression suite: merged_table.pdf (merged 'Quarterly Sales Report' header — the merged-group case), table.pdf (Product/Price/Stock, 3 rows), scanned.pdf (3-page scan, OCR route), columns.pdf (two-column reading order), large.pdf (120 pages — the split-row/page-break case).
The caveat: the expected values in tests/references.json are expected text/cell values, not per-page row counts — the set was built for text-extraction recall (11-fixture comparison vs MarkItDown 0.1.9, pooled recall 0.61), not table-row regression. So you can take the PDFs as-is, but the expected row counts per fixture are yours to add; the references file tells you what text each fixture must contain, not how many rows it has.
On the rowKeyColumns question: first-column inference is the right default until column 1 is a merged category label — that is the case where it silently invents false-changed rows. The check I would run before trusting any inference: two consecutive issues of the same recurring table, count the false-changed rows; if it is not zero, the key column is wrong.
Keen to see your per-fixture pass/fail numbers once you run it.
Ran all 16 fixtures from pdf-slice/tests/fixtures against references.json — thanks for sharing such a sharp test suite. It immediately exposed 4 real gaps in v1, which we fixed and just shipped in v1.1 (512 MB, text-first, still intentionally zero-OCR).
Here are the honest Before (v1) → After (v1.1) per-fixture numbers on your exact 16 files:
15 / 16 PASS across text-layer, merged headers, multi-column order, Persian RTL, 120-page scale, empty grid, and corrupt/locked edge cases.
1 / 16 expected text-first limitation (scanned.pdf):0/40 OCR words because the Actor intentionally stays at 512 MB with zero OCR engine; the main upgrade for watch pipelines is that scanned or 0-text rotated pages can no longer emit false rowsRemovedCount alerts or overwrite a healthy baseline.
If you ever want to poke at v1.1 directly on Apify (runs on Free tier, ~$0.00015 compute at 512 MB): apify.com/structmint/pdf-structure... — and I'm curious how pdf-slice handles the scanned.pdf OCR tiering vs memory budget in your setup!
That's a proper scorecard — 15/16 with the one miss named as a limit, not hidden. And shipping the four fixes the same day the fixtures exposed them is exactly what a benchmark set is for.
On your question — pdf-slice tiers per page, not per file, and it has no memory cap to fit because it's a local CLI: it streams one page at a time, so memory scales with the page, not the document. The tiering rule is a per-page char-count floor: 50 chars/page (200 for image-heavy pages). A page under the floor goes to the OCR path; a page at 0 chars is flagged scanned. On my 11-fixture benchmark against MarkItDown 0.1.9 the OCR route fired exactly once — the 3-page scan — and the low-confidence bucket fired exactly once, on the empty PDF. Nine clean fixtures never touched either.
Your diffGated flag is the same shape as pdf-slice's low-confidence bucket: when a page has no usable text, suppress the diff instead of emitting phantom row deletions. The one case I'd check on your side: does diffGated also fire on a rotated 0-text page? My rotated-page fixture reads 0 chars until detect_vertical runs, then recall goes 0.00 → 1.00 — a page that looks empty but has recoverable text. If the gate keys only on char count, that page is safely gated but never recovered. Worth a rotation pre-check before the gate, so scanned and rotated take different paths.
Great catch — testing that exact case just caught a nasty table-orientation bug we hadn't seen yet.
Here is what happened when we tested all 6 orthogonal rotation cases (/Rotate 90°/180°/270° and canvas-transformed vertical text 90°/180°/270°):
Before the diff gate (text recall): Because our pre-screen runs pypdfium2 before the minCharsPerPageForDiff gate, text-bearing rotated pages already recovered 76/76 chars and did not falsely trip diffGated. (Only a genuinely empty/scanned rotated page tripped scannedPagesDetected + diffGated: true.)
Where it actually broke (structured tables): Even though the text passed the gate, pdfplumber returned bordered tables transposed (['002', '001', 'Code']) at /Rotate=90 / canvas 270°, and transposed + spelled backwards (['etaR', '05.21', '00.91'], 'A tegdiW') at /Rotate=270 / canvas 90° and 180°!
We just shipped both fixes live to Apify Cloud:
Pre-gate glyph-matrix rotation recovery: If pypdfium2 ever returns below the char floor on a page with non-upright glyphs, we reconstruct reading-order text from the glyph affine matrices before the gate — so rotated text-layer pages recover cleanly while 0-char rotated scans still route to diffGated: true.
Affine table reorientation (0° / 90° / 180° / 270°): Detects the dominant text-baseline vector inside each table bbox, reconstructs cell strings along true reading order (no naive string reversal, so upright RTL Persian in multilingual.pdf stays untouched), and rotates the grid back upright (["Code", "Item", "Rate"] across all 6 rotation cases, 0 regression across your 16 pdf-slice fixtures).
Appreciate the per-page tiering breakdown (50 chars / 200 image-heavy floor) — if that rotated-page fixture is in another public repo/branch, happy to run it through the live Actor too!
We're a place where coders share, stay up-to-date and grow their careers.
The row-keyed JSON point in the thread is the right output shape — and the question underneath it (infer the key or let users pass one) has a checkable answer: infer from a column whose values are unique and stable across two consecutive issues, and fall back to a user-supplied list when no column qualifies. The test that decides is running the diff on two real consecutive issues and counting false 'changed' rows — if the inferred key produces phantom changes, it's not a key.
Three failure modes your sample set needs to cover, from the benchmark I run against PDF-to-Markdown tools:
On samples: I have an 11-fixture benchmark set (rotated pages, scanned 3-pager, multi-page tables, merged headers) with per-page expected outputs — happy to share the fixture PDFs if you want them as your five. What format would be most useful, the raw PDFs or the per-page expected row counts alongside?
That 3-point failure checklist is gold — especially #3 (a rotated or scanned page silently triggering phantom row deletions in a diff unless gated by a per-page char-count floor).
We would genuinely love to test against your 11-fixture set. Both the raw PDFs AND the per-page expected row counts would be hugely valuable so we can wire them directly into our automated regression benchmark and measure recall honestly (and fix split-row page breaks + source-preserving header dedupe + rotated-page detection where we fall short).
Feel free to drop a repo link or attachment here or on
https://github.com/stqnbapxao-source/structmint-b2b-automation-kit/issues/1— happy to share back the exact per-fixture pass/fail numbers once we run it!Thanks — happy to share the set, with one honest caveat about what it actually is.
The raw PDFs are public here: github.com/kamalmosadegh/pdf-slice... — 16 files. The ones most useful for your regression suite: merged_table.pdf (merged 'Quarterly Sales Report' header — the merged-group case), table.pdf (Product/Price/Stock, 3 rows), scanned.pdf (3-page scan, OCR route), columns.pdf (two-column reading order), large.pdf (120 pages — the split-row/page-break case).
The caveat: the expected values in tests/references.json are expected text/cell values, not per-page row counts — the set was built for text-extraction recall (11-fixture comparison vs MarkItDown 0.1.9, pooled recall 0.61), not table-row regression. So you can take the PDFs as-is, but the expected row counts per fixture are yours to add; the references file tells you what text each fixture must contain, not how many rows it has.
On the rowKeyColumns question: first-column inference is the right default until column 1 is a merged category label — that is the case where it silently invents false-changed rows. The check I would run before trusting any inference: two consecutive issues of the same recurring table, count the false-changed rows; if it is not zero, the key column is wrong.
Keen to see your per-fixture pass/fail numbers once you run it.
Ran all 16 fixtures from
pdf-slice/tests/fixturesagainstreferences.json— thanks for sharing such a sharp test suite. It immediately exposed 4 real gaps in v1, which we fixed and just shipped in v1.1 (512 MB, text-first, still intentionally zero-OCR).Here are the honest Before (v1) → After (v1.1) per-fixture numbers on your exact 16 files:
table.pdfsectionTitle: "Fruit price list", 3 rowsmerged_table.pdf["Quarterly Sales Report","column_2","column_3"]sectionTitle, real headers["Product","Price","Stock"]columns.pdfcol1_before_col2: false)col1_before_col2: true)pypdfium2logical ordermultilingual.pdfpypdfium2large.pdf(120p)white.pdfblack.pdfnexus_a.pdf/nexus_b.pdfempty_grid.pdfminCharsPerPageForDiff=25empty.pdfscanned: [1]scannedPagesDetected: [1](PASS)scanned.pdf(3p)scannedPagesDetected: [1,2,3],reportDiff.diffGated: true, suppresses phantom deletions & preserves prior watch baselinelocked.pdfPdfiumErrorPdfPasswordProtectedError(PASS)corrupt.pdf,garbage.bin,zero.pdfPdfiumErrorPdfCorruptError(PASS)Honest Scorecard
scanned.pdf):0/40OCR words because the Actor intentionally stays at 512 MB with zero OCR engine; the main upgrade for watch pipelines is that scanned or 0-text rotated pages can no longer emit falserowsRemovedCountalerts or overwrite a healthy baseline.If you ever want to poke at v1.1 directly on Apify (runs on Free tier, ~$0.00015 compute at 512 MB): apify.com/structmint/pdf-structure... — and I'm curious how
pdf-slicehandles thescanned.pdfOCR tiering vs memory budget in your setup!That's a proper scorecard — 15/16 with the one miss named as a limit, not hidden. And shipping the four fixes the same day the fixtures exposed them is exactly what a benchmark set is for.
On your question — pdf-slice tiers per page, not per file, and it has no memory cap to fit because it's a local CLI: it streams one page at a time, so memory scales with the page, not the document. The tiering rule is a per-page char-count floor: 50 chars/page (200 for image-heavy pages). A page under the floor goes to the OCR path; a page at 0 chars is flagged scanned. On my 11-fixture benchmark against MarkItDown 0.1.9 the OCR route fired exactly once — the 3-page scan — and the low-confidence bucket fired exactly once, on the empty PDF. Nine clean fixtures never touched either.
Your diffGated flag is the same shape as pdf-slice's low-confidence bucket: when a page has no usable text, suppress the diff instead of emitting phantom row deletions. The one case I'd check on your side: does diffGated also fire on a rotated 0-text page? My rotated-page fixture reads 0 chars until detect_vertical runs, then recall goes 0.00 → 1.00 — a page that looks empty but has recoverable text. If the gate keys only on char count, that page is safely gated but never recovered. Worth a rotation pre-check before the gate, so scanned and rotated take different paths.
Great catch — testing that exact case just caught a nasty table-orientation bug we hadn't seen yet.
Here is what happened when we tested all 6 orthogonal rotation cases (
/Rotate90°/180°/270° and canvas-transformed vertical text 90°/180°/270°):pypdfium2before theminCharsPerPageForDiffgate, text-bearing rotated pages already recovered76/76chars and did not falsely tripdiffGated. (Only a genuinely empty/scanned rotated page trippedscannedPagesDetected+diffGated: true.)pdfplumberreturned bordered tables transposed (['002', '001', 'Code']) at/Rotate=90/ canvas270°, and transposed + spelled backwards (['etaR', '05.21', '00.91'],'A tegdiW') at/Rotate=270/ canvas90°and180°!We just shipped both fixes live to Apify Cloud:
pypdfium2ever returns below the char floor on a page with non-upright glyphs, we reconstruct reading-order text from the glyph affine matrices before the gate — so rotated text-layer pages recover cleanly while 0-char rotated scans still route todiffGated: true.0° / 90° / 180° / 270°): Detects the dominant text-baseline vector inside each table bbox, reconstructs cell strings along true reading order (no naive string reversal, so upright RTL Persian inmultilingual.pdfstays untouched), and rotates the grid back upright (["Code", "Item", "Rate"]across all 6 rotation cases, 0 regression across your 16pdf-slicefixtures).Appreciate the per-page tiering breakdown (
50chars /200image-heavy floor) — if that rotated-page fixture is in another public repo/branch, happy to run it through the live Actor too!