Skip to content

estelacode/pdf_text_extractor

Repository files navigation

PDF Text Extractor

Overview

A web-based app to extract and parse text from PDFs using PyMuPDF and Llama-Parse. Interactive PDF upload and text display via Gradio, fully Dockerized for optional deployment.

Demo

gradio ui gradio_ui_text_extraction_methods Llama-Parse Output

Features

Functionality

  • Extracting text from PDFs using PyMuPDF
  • Processing and parsing text with Llama-Parse
  • Interactive web interface via Gradio for PDF upload and text display

Infrastructure / Deployment

  • Dockerized deployment for quick and reproducible setup
  • Architecture documentation with high-level, sequence, and flow diagrams

Architecture

High-level structure of the application: High Level Architecture Diagram

Sequence Diagram

Sequence Diagram

Sequence Flow:

  1. User uploads PDF via Frontend.
  2. Frontend receives the PDF.
  3. Frontend sends the PDF to the Backend for processing.
  4. Backend extract text with PyMuPDF from the PDF.
  5. Backend processes text with Llama-Parse.
  6. Backend returns results to Frontend.
  7. Frontend displays extracted text to user.

Tech Stack

Backend

Python 3.13.3 llama-cloud-services >=0.6.35 PyMuPDF >=1.26.1

Frontend

Gradio 5.34.2

Infrastructure | Dev Tools

Docker 28.4.0 uv 0.9.13

Setup

git clone https://github.com/estelacode/pdf_text_extractor.git
cd pdf_text_extractor

# Create & activate virtual environment
py -3.13 -m venv .venv
source .venv/bin/activate  # Linux/macOS
.venv\Scripts\activate     # Windows

# Install dependencies
uv pip install -e .

# Configure environment
Configure .env file (copy from .env.example)

Usage

uv run main.py
# Navigate to http://localhost:7860/

Project Structure

pdf_text_extractor/
├── .dockerignore        # Files and folders to exclude from Docker builds
├── .env                 # Environment variables (keep secret)
├── .env.example         # Example environment variables
├── .gitignore           # Git ignore rules
├── .python-version      # Python version used in the project
├── .venv/               # Local virtual environment (ignored in git)
├── data/                # Folder for input/output data (PDFs, extracted text, etc.)
├── dist/                # Distribution or build files
├── docs/                # Documentation files
├── main.py              # Entry point of the application
├── notebook/            # Jupyter notebooks for experiments or testing
├── pyproject.toml       # Project dependencies and metadata
├── README.md            # Project README file
├── Dockerfile           # Dockerfile to build the container
├── src/                 # Source code for the project
└── uv.lock              # Dependency lock file for uv

Roadmap

  • Improve text extraction: Maintain original structure, including paragraphs, headings, and columns
  • Add image extraction: Detect and save images from PDFs.
  • Add table extraction: Detect tables and export them as CSV or JSON.
  • Add API endpoints: Expose extraction and parsing methods as HTTP services (extract, parse, retrieve).
  • Add automated tests
  • Deploy to cloud: Make the app accessible from anywhere

DevOps/ Build / Deployment

Build the artifact

# Generate the whl file in the dist folder
uv build 

Docker Deployment

# Build Docker image
docker build -t pdf_text_extractor .

# Run Docker container
docker run -d -p 8080:8080 pdf_text_extractor

# Run Docker container with environment variables
docker run -d -p 8080:8080 -e LLAMA_CLOUD_API_KEY="YOUR_API_KEY" pdf_text_extractor

References

Tools & Frameworks

PDF Procesing Libraries

👋 Author

Estela Madariaga

About

Create an app to extract text from PDFs

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages