https://github.com/alisafaya/txt-from-pdf
Extracting clean text from pdfs using pdfminer.six and pypdf.
https://github.com/alisafaya/txt-from-pdf
pdf pdf-document-processor text-mining
Last synced: 6 months ago
JSON representation
Extracting clean text from pdfs using pdfminer.six and pypdf.
- Host: GitHub
- URL: https://github.com/alisafaya/txt-from-pdf
- Owner: alisafaya
- License: apache-2.0
- Created: 2024-04-18T12:26:52.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-27T16:28:44.000Z (almost 2 years ago)
- Last Synced: 2025-09-20T13:29:12.553Z (10 months ago)
- Topics: pdf, pdf-document-processor, text-mining
- Language: Python
- Homepage:
- Size: 52.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# txt-from-pdf: Extract clean text from PDFs
[](https://github.com/alisafaya/txt-from-pdf/releases)
[](https://badge.fury.io/py/txt-from-pdf)
[](./LICENSE)
Extracting text from pdfs using [pymupdf](https://github.com/pymupdf/PyMuPDF/), but with a focus on cleaning and formatting the extracted text.
# Installation
```bash
pip install txt-from-pdf
```
# Usage
```python
from txtfrompdf import extract_txt_from_pdf
pdf_path = "file.pdf"
text = extract_txt_from_pdf(pdf_path)
print(text)
```
# CLI Usage
Single file:
```bash
txt-from-pdf --input file.pdf --output extracted-text
```
Multiple files in a directory:
```bash
txt-from-pdf --input dir-with-pdfs --output extracted-text
```
Detailed help:
```bash
usage: txt-from-pdf [-h] --input INPUT [--output OUTPUT] [--no_filter] [--size SIZE]
txt-from-pdf CLI - Extracts cleaned text from PDF files
options:
-h, --help show this help message and exit
--input INPUT Path to a folder containing PDFs or to a single PDF file. (Required)
--output OUTPUT Output location for the extracted text files. (Optional, default: 'extracted_text')
--no_filter Turn off cleaning the resulting text files. (Optional)
```