Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

PDF to Excel Converter

This application provides a user-friendly interface that allows users to convert PDF files into Excel format. It supports multiple extraction options, including table detection, text extraction, and OCR (Optical Character Recognition) for scanned documents.


Features

  1. PDF Table to Excel: Extracts tables from a PDF and saves them into an Excel file.
  2. PDF Table/Sheet Excel: Extracts multiple tables from a PDF and saves each table into a separate sheet in an Excel file.
  3. PDF to Excel: Extracts all text from a PDF and saves it into an Excel file.
  4. OCR: Uses Optical Character Recognition to extract text from scanned PDFs and saves it into an Excel file.

Requirements

  • Python 3.x
  • PyQt5
  • pdfplumber
  • pandas
  • PyMuPDF (fitz)
  • pdf2image
  • easyocr
  • opencv-python (cv2)
  • numpy
  • poppler (+Add to PATH)

Installation

  1. Install the required Python packages:

    pip install PyQt5 pdfplumber pandas pymupdf pdf2image easyocr opencv-python numpy

Clone or Download the Repository


How to Run the Project

Option 1: Using the Web Interface (Backend + Frontend)

Start the Backend Server:

  1. Make sure all dependencies are installed:

    python -m pip install -r requirements.txt
  2. Start the Flask backend server:

    python backend.py

    The server will start on http://localhost:5000

Start the Frontend:

  1. Open index.html in your web browser, or
  2. Use a local web server:

python -m http.server 8000

Then navigate to `http://localhost:8000` in your browser

### Option 2: Using the Desktop GUI Application

Run the PyQt5 desktop application:
```bash
python PDF-to-Excel.py

Usage

Select a PDF File:

Click the "File" button to select a PDF file from your system.

Choose an Option:

Select one of the available options:

  • PDF Table to Excel: Extracts tables from the PDF.
  • PDF Table/Sheet Excel: Extracts multiple tables and saves each in a separate sheet.
  • PDF to Excel: Extracts all text from the PDF.
  • OCR: Uses OCR to extract text from scanned PDFs.

Save the Output:

Click the "Ok" button to choose the output location and save the Excel file.

Code Structure

PdfConverter Class

This class contains static methods for handling PDF conversion:

  • convert_pdf_table_to_excel(pdf_path, output_file): Extracts tables from a PDF and saves them into an Excel file.
  • extract_tables_from_pdf(pdf_path): Extracts multiple tables from a PDF.
  • export_tables_to_excel(tables, output_excel_path): Exports extracted tables to an Excel file.
  • convert_pdf_text_to_excel(pdf_path, output_file): Extracts all text from a PDF and saves it into an Excel file.
  • process_ocr(pdf_path, output_file): Uses OCR to extract text from scanned PDFs.
  • export_to_excel(detections, output_file): Exports OCR-detected text to an Excel file.

Ui_MainWindow Class

This class defines the GUI for the application:

  • setupUi(MainWindow): Sets up the main window, buttons, and options.
  • retranslateUi(MainWindow): Sets the text for UI elements.
  • openFileDialog(): Opens a file dialog to select a PDF file.
  • onOkButtonClicked(): Handles the conversion process based on the selected option.

Example

  1. Launch the application.
  2. Select a PDF file using the "File" button.
  3. Choose an option (e.g., "PDF Table to Excel").
  4. Click "Ok" and select the output location.
  5. The application will generate an Excel file with the extracted data.

Notes

  • Ensure that the selected PDF file is not corrupted or password-protected.
  • For OCR functionality, the PDF should contain scanned images of text.

License

This project is open-source and available under the GPL v3 License.

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages