DEV Community

Why PDF-to-Markdown breaks recurring tables in n8n/Make — looking for 5 public sample PDFs before building anything

StructMint on December 06, 2026

If you’ve ever wired a recurring PDF report (fee schedule, tariff update, public catalog, regulatory bulletin) into n8n or Make, you’ve probably se...
Collapse
 
kamalmosadegh profile image
Kamal Mosadegh •

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:

  1. 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.
  2. 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).
  3. 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?

Collapse
 
structmint profile image
StructMint •

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!

Collapse
 
kamalmosadegh profile image
Kamal Mosadegh •

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.

Thread Thread
 
structmint profile image
StructMint •

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:

Fixture v1 (Before) v1.1 (After) Latency / Py Heap Notes
table.pdf 12/12 cells (PASS) 12/12 cells (PASS) 7.1 ms / 0.39 MB Clean sectionTitle: "Fruit price list", 3 rows
merged_table.pdf 10/10 cells, broken header ["Quarterly Sales Report","column_2","column_3"] 10/10 cells (PASS) — promoted banner to sectionTitle, real headers ["Product","Price","Stock"] 7.5 ms / 0.38 MB Fixed merged title-banner promotion
columns.pdf 2/2 markers, interleaved lines (col1_before_col2: false) 2/2 markers, clean Col 1 → Col 2 order (col1_before_col2: true) 11.0 ms / 0.88 MB Switched prose path to pypdfium2 logical order
multilingual.pdf EN 13/13, FA 0/14 (FAIL) EN 13/13, FA 14/14 (100% PASS) 8.4 ms / 0.41 MB Fixed RTL/Unicode extraction via pypdfium2
large.pdf (120p) 120/120p (18.64 MB heap) 120/120p (PASS) 214.2 ms / 1.44 MB ~12x lower Python heap via per-page streaming
white.pdf body 8/8, hdr 5/5 (PASS) body 8/8, hdr 5/5 (PASS) 12.1 ms / 0.83 MB Clean
black.pdf body 8/8, hdr 5/5 (PASS) body 8/8, hdr 5/5 (PASS) 75.8 ms / 0.83 MB Clean (cold first file)
nexus_a.pdf / nexus_b.pdf 3/3 each (PASS) 3/3 each (PASS) 6.5 / 6.3 ms / 0.28 MB Clean
empty_grid.pdf 0 tables, false scanned alarm 0 tables, 0 false scanned warnings (PASS) 5.1 ms / 0.13 MB 28 chars cleanly above minCharsPerPageForDiff=25
empty.pdf 0 chars, scanned: [1] 0 chars, flagged scannedPagesDetected: [1] (PASS) 4.7 ms / 0.02 MB Clean
scanned.pdf (3p) 0/40 OCR words (FAIL) 0/40 OCR words (honest text-first limit) 5.0 ms / 0.11 MB Now sets scannedPagesDetected: [1,2,3], reportDiff.diffGated: true, suppresses phantom deletions & preserves prior watch baseline
locked.pdf Raw PdfiumError Clean PdfPasswordProtectedError (PASS) 0.8 ms / 0.0 MB Explicit encrypted-PDF error
corrupt.pdf, garbage.bin, zero.pdf Raw PdfiumError Clean PdfCorruptError (PASS) <=0.1 ms / 0.0 MB Explicit malformed/0-byte errors

Honest Scorecard

  • 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!

Thread Thread
 
kamalmosadegh profile image
Kamal Mosadegh •

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.

Thread Thread
 
structmint profile image
StructMint •

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°):

  1. 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.)
  2. 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!