duncanmcqueen is giving legal PDFs their structure back

A proposed overhaul would make extracted legal text more faithful before it reaches chat, quotes, and document workflows.

knowledge-managementsearch

PDFs often look orderly to a reader but arrive as a jumble of tiny text fragments. Duncanmcqueen's proposed approach rebuilds the page from its layout, rather than treating every fragment as ordinary prose.

  • Reconstructs lines and wrapped clauses in their intended reading order.
  • Avoids false spaces inside words split by PDF typography.
  • Retains paragraph breaks, indentation, and limited column spacing for items such as signature blocks and simple tables.
  • Keeps page order and existing fallbacks for PDFs whose text cannot be read.

That matters because the same extracted text feeds document chat and citation matching: better source text should mean answers and quoted passages that track the original document more closely.

So what Legal teams using PDF-heavy matter files should care because small layout errors can turn into misleading context or unreliable citations.

View this fork on GitHub →

Spotted something wrong? Or know the PR text has fresher detail than the writeup above?