DEV Community

StructMint
StructMint

Posted on

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

If you’ve ever wired a recurring PDF report (fee schedule, tariff update, public catalog, regulatory bulletin) into n8n or Make, you’ve probably seen the same failure mode:

  • Plain text / Markdown extractors flatten multi-column tables into single lines ("Tables come out as text lines").
  • Passing every page through an LLM every week gets expensive and introduces silent numeric hallucinations.
  • Even when extraction works, you still have to build custom diff logic just to answer: "Which table rows changed since last month’s PDF?"

Before writing a single line of production code for a lightweight text-first parser + change watcher (no OCR, no monthly SaaS lock-in), I’m running an open pre-build validation until December 19, 2026.

If you deal with recurring public, non-confidential text-based PDFs, I’d genuinely appreciate 2 minutes of feedback on the open RFC issue:
https://github.com/stqnbapxao-source/structmint-b2b-automation-kit/issues/1

Specifically looking for:

  1. One public sample PDF URL where current parsers mangle tables.
  2. What clean JSON/CSV table or row-diff output you’d actually feed into n8n/Make.
  3. Monthly document volume and what pay-per-use price feels reasonable (e.g., $0.005/PDF, $0.002/table, or $0.01/report-diff).

(Full disclosure: Pre-build research only — no product or checkout exists. If existing low-cost tools already cover this well enough, I’ll close the RFC and skip building it.)

Top comments (14)

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!

Thread Thread
 
kamalmosadegh profile image
Kamal Mosadegh •

Thank you for running all six — that settles my question cleanly: diffGated fires only on genuinely 0-char rotated pages, and text-bearing rotated pages recover through the glyph-matrix path before the gate. The bigger finding is the table one: the text gate passed while pdfplumber transposed the tables silently. A green text check hiding a wrong table is exactly the silent-failure class this thread is about — worth a table-shape assertion next to the char-count gate (row count plus first-cell value per page), so a transposed grid fails loudly instead of indexing wrong. And good call keeping upright RTL untouched; a naive string reversal would have broken Persian.

One cross-check from my side: I'll run the same six rotation cases through pdf-slice's table path and post back whether any orientation transposes there too. If it holds everywhere except pdfplumber, it's one library's geometry assumption; if it breaks in both, it's a more general lesson about reading order. Thanks for turning the question into a shipped fix.

Thread Thread
 
kamalmosadegh profile image
Kamal Mosadegh •

That transposed-table catch is the real find — and the nastier failure mode of the two. The text gate passing while the grid silently transposes means recall stays green while the structure is wrong, and a diff built on that table would report phantom row changes that never happened. Good that the fix keys on the dominant baseline vector instead of naive string reversal — that is exactly what keeps the upright RTL Persian in multilingual.pdf untouched.

On the fixture question, one honest correction: the rotated-page case is not a standalone file in the public tests/fixtures set. The 16 files are table, merged_table, columns, multilingual, scanned, large, empty, empty_grid, white, black, nexus_a/b, locked, corrupt, garbage.bin and zero — no rotated variant. The 0.00 → 1.00 number came from a rotated variant in the MarkItDown benchmark, not a committed fixture. The closest public stand-in is table.pdf itself rotated 90°: same 12-cell grid, expected values already in references.json (table_cells). If a committed rotated variant of table.pdf would help, I can add one to the fixtures; or run the live Actor against a 90° rotation of table.pdf and compare the grid before and after the affine fix.

One check I'd still run on the affine reorientation: a mixed-direction table — upright Latin headers with RTL cell values in the same grid. The baseline vector is Latin-dominated, so the RTL cells should ride along untouched, but that is the case where a rotation fix can quietly re-order cell contents. multilingual.pdf doesn't cover it — its Persian is prose, not a table.

Thread Thread
 
structmint profile image
StructMint •

Just ran both checks you suggested — super clean signal on both:

  1. Your table.pdf rotated 90° and 270° (/Rotate set via pypdfium2):

    • Both orientations recovered 12/12 cells upright (headers: ['Product', 'Price', 'Stock'], rows Apple / $1.20 / 120, Banana / $0.80 / 200, Cherry / $2.50 / 75, scanned: [], diffGated: false).
    • Adding a committed rotated table.pdf variant to pdf-slice/tests/fixtures would honestly be a great public benchmark for the whole PDF ecosystem — lots of libraries silently transpose there.
  2. Mixed-direction table (upright Latin headers ['Code', 'Product', 'Price'] + Persian RTL cells 'سلام دنیا' & 'فارسی تست'):

    • Upright (angle=0): Bypassed affine reorientation completely (angle == 0 short-circuit) and returned exact strings ('سلام دنیا', 'فارسی تست').
    • Rotated 90° (angle=270 baseline): Recovered upright headers and exact Persian cell strings cleanly too.
    • One honest caveat: That synthetic mixed table stored logical-order Unicode TTF glyphs. For PDFs emitted by visual-order RTL generators (Arabic Presentation Forms stored left-to-right on the page like multilingual.pdf), pypdfium2 prose handles bidi shaping cleanly while pdfplumber cell text still follows raw glyph-x order unless normalized — definitely worth keeping an eye on if a visual-order mixed RTL table fixture turns up.

Really curious to see how pdf-slice's table path behaves across those 6 rotation orientations too — and good tip on adding a table-shape regression assertion next to the char-count gate!

Thread Thread
 
kamalmosadegh profile image
Kamal Mosadegh •

Ran the six through pdf-slice's table path — current main (commit f68b63a, extract.py 1.1.0), same table.pdf, expected grid Product/Price/Stock × Apple/$1.20/120, Banana/$0.80/200, Cherry/$2.50/75. 0/6 come back correct, and it splits into two failure modes:

  • /Rotate 90/180/270: the table is detected but every cell comes back empty, with the 'table detected but all cells are empty' warning. Loud, not silent — the text itself extracts fine as paragraphs, but the grid is lost.
  • Canvas-transformed 90/180/270 (same page placed as a rotated Form XObject, /Rotate 0): the grid comes back well-formed but wrong, with no warning. 90° and 270° transpose it — rows become columns, so Stock/120/200/75 is the header row at 90°. 180° inverts it — rows and columns both reversed, Stock/Price/Product ends up as the last row. Values intact, structure wrong.

So it breaks in both, not just pdfplumber — the difference is where: pdfplumber transposes and reverses characters, pdf-slice transposes without reversing but loses the /Rotate grids entirely. The fix on my side is the same shape as yours: a rotation pre-check before the table path, or a table-shape assertion (row count + first-cell value) next to the char-count gate so a transposed grid fails loudly instead of indexing wrong.

The mixed-direction result is the clean part — both checks passing with the RTL cells untouched is exactly what the baseline-vector fix should do. And your visual-order RTL caveat is real: pdfplumber cell text follows raw glyph-x order there, so a visual-order mixed RTL table fixture would be worth having if one turns up.

Thread Thread
 
structmint profile image
StructMint •

Thanks for running all 6 through pdf-slice and reporting the exact split — that's one of the clearest cross-library diagnoses I've seen on PDF table extraction.

I just reproduced your exact Form XObject setup against your table.pdf (placing page 0 onto a /Rotate 0 blank page with 90° / 180° / 270° affine transforms via FPDF_NewXObjectFromPage + FPDFPageObj_Transform) alongside /Rotate 90° / 180° / 270° on pdf-structured-tables-watch v1.1:

  • /Rotate 90° / 180° / 270°: 3/3 PASS (headers: ['Product', 'Price', 'Stock'], exact 3 rows, scanned: [])
  • Form XObject 90° / 180° / 270° (/Rotate 0): 3/3 PASS (headers: ['Product', 'Price', 'Stock'], exact 3 rows, scanned: [])

The contrast you surfaced — /Rotate failing loudly with empty cells vs. rotated Form XObjects (/Rotate 0) silently transposing Stock / 120 / 200 / 75 into the header row with zero warning — is a textbook case for putting a table-shape sanity check (or glyph baseline-angle check) right next to the char-count gate.

Really appreciate you cross-testing this in the open. If you ever do publish a rotated table.pdf (or a visual-order mixed RTL fixture) into pdf-slice/tests/fixtures, drop a note — happy to keep running regression passes against it.

Thread Thread
 
kamalmosadegh profile image
Kamal Mosadegh •

Thanks for the clean reproduction — 6/6 on your side against 0/6 on pdf-slice's table path is exactly the contrast worth having in the open: /Rotate fails loudly with empty cells, the Form XObject cases fail silently with a transposed grid. I'll add a committed rotated variant of table.pdf to the fixtures and post the link here when it's in — and I'll keep an eye out for a visual-order mixed RTL table fixture, since that's the case neither of us has covered yet. Keen to see your regression numbers once the rotated variant lands.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.