learning-it by example

Back to the video

RAG Over PDFs: Check Your Extracted Text Before You Index

One page of my PDF came back with no text of its own, and nothing warned me.

Video #44 ยท RAG and vector search

Steps in the video

  1. 0:00 One page of my PDF had no text of its own
  2. 0:31 The idea
  3. 1:06 Setup
  4. 1:35 A handbook with four problems
  5. 2:08 Three ways to extract
  6. 2:32 Four checks
  7. 3:28 What this does not show
  8. 3:58 Mistakes to avoid
  9. 4:22 My take and next steps
  10. 4:56 Recap

Files

  • compare.py (17 lines)
  • extract.py (26 lines)
  • make_pdf.py (43 lines)

Download the code (zip)

Tested with

Python 3.12.15 | pypdf==6.21.4, fpdf2==2.8.9, pdfplumber==0.11.10, pillow==13.0.0

What this does not show

The PDF is generated by code, which is the easy case. Real PDFs have two columns, rotated text, odd fonts and merged table cells, and will be messier. No OCR was run, so the scanned page is only detected, not read. One small table is a very small test.

Sources

Learning IT by Example.