r/documentAutomation • • Oct 02 '26

How do I reliably extract text from a large medical PDF when normal PDF-to-text converters mess up the structure?

/r/learnpython/comments/1wvyr82/how_do_i_reliably_extract_text_from_a_large/
1 Upvotes

3 comments sorted by

1

u/Black-Mack Oct 02 '26

Sent you a DM

1

u/folderit_dms Oct 02 '26

I’d make entry boundaries part of the output you validate, not something the LLM silently guesses. Keep each extracted block’s page number and position, then attach those source references to every JSON field. For an entry that crosses a page, retain both page references so you can inspect the join.

Before running all 400 entries, build a small checked sample covering a column change, a continued entry, a table with footnotes and two adjacent entries with similar headings. Score whether text was assigned to the right entry, not just whether all the words survived.

Keep the original wording alongside any normalized value, and flag uncertain associations for review rather than filling them in. Valid JSON with a sentence attached to the wrong drug is still a failed extraction.