Skip to content

siva23367/PDF-Parsing-and-Structured-JSON-Extraction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📄 PDF to JSON Parser

A Python tool that extracts structured content (paragraphs, tables, charts) from PDF documents and converts it into a hierarchical JSON format.

Built using:


🎯 Features

  • Extracts:
    • 📝 Paragraphs with section/subsection context
    • 📊 Tables (structured data)
    • 📈 Charts (embedded images)
  • Maintains page-level hierarchy
  • Exports clean, well-structured JSON
  • Interactive Streamlit web interface
  • Download extracted JSON directly

⚙️ Installation

1. Clone the repository

git clone <your-repo-url>
cd <your-repo-folder>

2. Create & activate virtual environment (recommended)

python -m venv venv
source venv/bin/activate   # On Linux/Mac
venv\Scripts\activate      # On Windows

3. Install dependencies

pip install -r requirements.txt

🚀 Usage

Run the Streamlit app

streamlit run app.py

Steps

  1. Upload a PDF file (resume, factsheet, etc.)
  2. Click Process PDF
  3. Preview extracted content (page-wise)
  4. Download the JSON output

📂 Project Structure

.
├── app.py              # Streamlit web app
├── pdf_parser.py       # Core parser (paragraph, table, chart extraction)
├── utils/
│   └── styling.py      # Custom CSS for Streamlit UI
├── requirements.txt    # Python dependencies
└── README.md           # Project instructions

📊 Example JSON Output

{
  "pages": [
    {
      "page_number": 1,
      "content": [
        {
          "type": "paragraph",
          "section": "FACTSHEET",
          "sub_section": null,
          "text": "June 2025 Mutual Fund investments are subject to market risks..."
        },
        {
          "type": "chart",
          "section": "FACTSHEET",
          "sub_section": null,
          "description": "Embedded image detected - possible chart",
          "image_index": 1
        },
        {
          "type": "table",
          "section": "Financial Data",
          "sub_section": null,
          "table_data": [
            ["Year", "Revenue", "Profit"],
            ["2022", "$10M", "$2M"]
          ]
        }
      ]
    }
  ]
}

📝 Notes

  • Paragraphs are detected using regex-based section/subsection rules.
  • Tables are extracted only if the PDF has true tabular structures.
  • Charts are flagged when images are found (exported as metadata, not raw image files).
  • For scanned PDFs, OCR (e.g., Tesseract) would be required (not included here).

✅ Assignment Requirements Covered

  • Input: PDF → Output: JSON
  • Maintains page hierarchy
  • Detects paragraphs, tables, charts
  • Preserves sections & subsections
  • Exportable JSON + Streamlit UI

About

Our task is to build a Python program that parses a PDF file and extracts its content into a well-structured JSON format.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages