Skip to main content

PDF Structured Text Extractor

A small PDF text extraction tool built on pdfplumber.

It tries normal text extraction first. If that fails (bad encoding, weird fonts, some scanned or broken text layers), it falls back to grouping words by their position on the page to rebuild the text.


Features

  • Direct text extraction first, spatial grouping as a fallback.
  • Groups words by distance to rebuild line order.
  • Runs locally, no API calls or cloud dependency.
  • One import, one function call.

Limitations

  • Multi-column layouts can get mixed up. The grouping just looks at nearest-neighbor distance, with no real column detection. Two-column resumes (sidebar + main content) can end up interleaved.
  • No OCR. If a PDF is a scanned image with no text layer, this returns "No text found." Use something like pytesseract alongside it if you need OCR.
  • Threshold isn't tuned rigorously. The threshold value (PDF points, not pixels) works on the documents it was tested on, but hasn't been validated on a bigger dataset. You may need to adjust it for other layouts.
  • Not a full layout engine. For serious table/column reconstruction, look at pdfminer.six (layout mode), PyMuPDF, or unstructured — they're more mature. This is a simpler fallback, not a replacement for those.

How It Works

  1. Try pdfplumber.page.extract_text() directly.
  2. If that returns nothing:
    • Get word bounding boxes.
    • Measure horizontal/vertical distance between words.
    • Group nearby words into lines.
    • Join lines in reading order.

Installation

pip install pdf-structured-extractor

Or from source:

git clone https://github.com/2005MohitInamdar/pdf_Text_Extraction
cd pdf_Text_Extraction
pip install -r requirements.txt

Usage

from pdf_resume_extractor import extract_text_from_pdf

text = extract_text_from_pdf("path/to/document.pdf")
print(text)

Comparison

Approach Speed Needs Internet Accuracy (text PDFs) Accuracy (scanned PDFs) Cost
This tool Fast, local No High Low (no OCR) Free
OCR tools (Tesseract, etc.) Slower No Medium-High Good Free
AI/NLP APIs Slower, cloud Yes High Very High Paid

Ideas for Contribution

  • Basic column detection
  • Optional OCR fallback for scanned PDFs
  • A test set of PDFs (text, scanned, multi-column, tables) to check accuracy against

License

MIT (change if you're using something else)


Contributing

Issues and PRs welcome, especially PDFs that break the grouping logic.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdf_resume_extractor-0.1.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdf_resume_extractor-0.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file pdf_resume_extractor-0.1.0.tar.gz.

File metadata

  • Download URL: pdf_resume_extractor-0.1.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.0

File hashes

Hashes for pdf_resume_extractor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0968344fa6a2ccd0b2ab093326cb803d8848740b57c7b71e5837098ec76b180c
MD5 540812f3a236670b212936ae8c6098f6
BLAKE2b-256 1fdad037790e6964177cc89cec6dae4fb3084b880334ded122b8f5d1efafd714

See more details on using hashes here.

File details

Details for the file pdf_resume_extractor-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pdf_resume_extractor-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4dd2f0cbe6aca109cff366ab2c2ca97103b2963fa7a4be69ddf0c8a243a9f6ca
MD5 4444112d093b1f82febf4a5965a7b223
BLAKE2b-256 56db7dbd0269ea9536ec3d63b8d0adcea1d45966a010fb156fab9d46dded28f5

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page