Metadata-Version: 2.4
Name: pdf_resume_extractor
Version: 0.1.0
Summary: Local PDF text extraction with a spatial word-grouping fallback for pages that resist direct extraction.
Author: Mohit Inamdar
License: MIT
Project-URL: Homepage, https://github.com/2005MohitInamdar/pdf_Text_Extraction
Project-URL: Issues, https://github.com/2005MohitInamdar/pdf_Text_Extraction/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pdfplumber>=0.10.0
Dynamic: license-file

# PDF Structured Text Extractor

A small PDF text extraction tool built on [`pdfplumber`](https://github.com/jsvine/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`](https://github.com/madmaze/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

```bash
pip install pdf-structured-extractor
```

Or from source:

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

---

## Usage

```python
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.
