Skip to content

tapanij/pdf-rectangle-selection-tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PDF Rectangle Selection Tool

A Python-based GUI application that allows you to visually select rectangular regions in PDF files and extract text from those regions.

Features

  • 📄 Open and view PDF files
  • 🔍 Zoom in/out for better precision
  • ✏️ Draw rectangles to select text regions
  • 📝 Extract text from selected regions
  • 🖱️ Simple and intuitive mouse-based interface
  • 📑 Navigate through multi-page PDFs

Requirements

  • Python 3.8 or higher
  • PyMuPDF (fitz)
  • Pillow
  • tkinter (usually comes with Python)

Installation

  1. Clone or download this repository:
git clone <repository-url>
cd pdf-rectangle-selection-tool
  1. Install the required dependencies:
pip install -r requirements.txt

Usage

  1. Run the application:
python main.py
  1. Click "Open PDF" to load a PDF file

  2. Use the mouse to draw rectangles around text you want to extract:

    • Click and hold the left mouse button
    • Drag to create a rectangle
    • Release to finalize the selection
  3. Click "Extract Text" to extract text from all selected regions

  4. The extracted text will appear in the right panel

Controls

  • Open PDF: Load a PDF file
  • Previous/Next Page: Navigate through pages
  • Zoom In/Out: Adjust the zoom level
  • Reset Zoom: Return to 100% zoom
  • Extract Text: Extract text from selected rectangles
  • Clear Selection: Remove all selected rectangles

Tips

  • Use zoom to select text more precisely
  • Multiple rectangles can be selected before extraction
  • Rectangles are cleared when changing pages
  • Text extraction quality depends on the PDF's text layer

Troubleshooting

If you encounter any issues:

  1. Ensure all dependencies are installed correctly
  2. Make sure the PDF file is not corrupted
  3. Try adjusting the zoom level for better selection accuracy

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

About

A Python-based GUI application that allows you to visually select rectangular regions in PDF files and extract text from those regions.

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages