.gitattributes CHANGED
@@ -33,3 +33,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ OCR[[:space:]]Extracter[[:space:]]web[[:space:]]app[[:space:]]-[[:space:]]for[[:space:]]pdf/processed/ocr_6bf37a2b-75cf-4698-afaf-d6edeeecdb55_sample_report.pdf filter=lfs diff=lfs merge=lfs -text
37
+ OCR[[:space:]]Extracter[[:space:]]web[[:space:]]app[[:space:]]-[[:space:]]for[[:space:]]pdf/processed/ocr_e9869372-a4ab-4e20-82b6-09ce6180bb97_Aug.pdf filter=lfs diff=lfs merge=lfs -text
38
+ OCR[[:space:]]Extracter[[:space:]]web[[:space:]]app[[:space:]]-[[:space:]]for[[:space:]]pdf/uploads/6bf37a2b-75cf-4698-afaf-d6edeeecdb55_sample_report.pdf filter=lfs diff=lfs merge=lfs -text
39
+ OCR[[:space:]]Extracter[[:space:]]web[[:space:]]app[[:space:]]-[[:space:]]for[[:space:]]pdf/uploads/e9869372-a4ab-4e20-82b6-09ce6180bb97_Aug.pdf filter=lfs diff=lfs merge=lfs -text
OCR Extracter web app - for pdf/Dockerfile ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ # Install system dependencies required for ocrmypdf
4
+ RUN apt-get update && apt-get install -y \
5
+ ocrmypdf \
6
+ tesseract-ocr \
7
+ poppler-utils \
8
+ libsnappy-dev \
9
+ zlib1g-dev \
10
+ libbz2-dev \
11
+ libreadline-dev \
12
+ libsqlite3-dev \
13
+ wget \
14
+ curl \
15
+ llvm \
16
+ libncurses5-dev \
17
+ libncursesw5-dev \
18
+ xz-utils \
19
+ tk-dev \
20
+ libssl-dev \
21
+ libffi-dev \
22
+ liblzma-dev \
23
+ python3-dev \
24
+ libopenjp2-7-dev \
25
+ libharfbuzz-dev \
26
+ libfribidi-dev \
27
+ libxcb-composite0-dev \
28
+ libatlas-base-dev \
29
+ git \
30
+ gcc \
31
+ && rm -rf /var/lib/apt/lists/*
32
+
33
+ WORKDIR /app
34
+
35
+ COPY requirements.txt .
36
+ RUN pip install --no-cache-dir -r requirements.txt
37
+
38
+ COPY . .
39
+
40
+ EXPOSE 7860
41
+
42
+ CMD ["python", "app.py"]
OCR Extracter web app - for pdf/Dockerfile.hf ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM huggingface/transformers-all-deepspeed:latest
2
+
3
+ # Install ocrmypdf and its dependencies
4
+ RUN apt-get update && apt-get install -y \
5
+ ocrmypdf \
6
+ tesseract-ocr \
7
+ poppler-utils \
8
+ && rm -rf /var/lib/apt/lists/*
9
+
10
+ WORKDIR /app
11
+
12
+ COPY requirements.txt .
13
+ RUN pip install --no-cache-dir -r requirements.txt
14
+
15
+ COPY . .
16
+
17
+ EXPOSE 7860
18
+
19
+ CMD ["python", "app.py"]
OCR Extracter web app - for pdf/README.md ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Document Converter Pro
2
+
3
+ A powerful document conversion tool that combines PDF OCR conversion and Excel to CSV conversion in a single interface.
4
+
5
+ ## Features
6
+
7
+ - **PDF OCR Conversion**: Convert scanned PDFs to searchable, text-based PDFs using ocrmypdf
8
+ - **Excel to CSV Conversion**: Convert Excel files to CSV format quickly and efficiently
9
+ - **Web Interface**: Built with Gradio for an intuitive user experience
10
+ - **Optimized Processing**: Fast conversion with optimized parameters
11
+
12
+ ## Deployment to Hugging Face Spaces
13
+
14
+ This application is ready to be deployed on Hugging Face Spaces as a free, public application.
15
+
16
+ ### Steps to Deploy:
17
+
18
+ 1. **Sign up on Hugging Face**
19
+ - Go to [huggingface.co](https://huggingface.co) and create an account
20
+
21
+ 2. **Create a New Space**
22
+ - Click on your profile icon → "New Space"
23
+ - Fill in the details:
24
+ - Name: Choose a unique name for your application
25
+ - License: Select appropriate license
26
+ - SDK: Select "Docker" (required for ocrmypdf)
27
+ - Visibility: Public or Private
28
+
29
+ 3. **Configure the Space**
30
+ - Use the files provided in this repository:
31
+ - `app.py` - Main application file
32
+ - `requirements.txt` - Python dependencies
33
+ - `Dockerfile` - Container configuration (see below)
34
+
35
+ 4. **Create a Dockerfile** (needed for ocrmypdf dependencies)
36
+ ```Dockerfile
37
+ FROM huggingface/transformers-all-deepspeed:latest
38
+
39
+ RUN apt-get update && apt-get install -y \
40
+ ocrmypdf \
41
+ tesseract-ocr \
42
+ poppler-utils \
43
+ && rm -rf /var/lib/apt/lists/*
44
+
45
+ COPY requirements.txt .
46
+ RUN pip install -r requirements.txt
47
+
48
+ COPY . .
49
+
50
+ CMD ["python", "app.py"]
51
+ ```
52
+
53
+ 5. **Alternative Dockerfile** (lighter image)
54
+ ```Dockerfile
55
+ FROM python:3.10-slim
56
+
57
+ # Install system dependencies
58
+ RUN apt-get update && apt-get install -y \
59
+ ocrmypdf \
60
+ tesseract-ocr \
61
+ poppler-utils \
62
+ gcc \
63
+ && rm -rf /var/lib/apt/lists/*
64
+
65
+ WORKDIR /app
66
+
67
+ COPY requirements.txt .
68
+ RUN pip install -r requirements.txt
69
+
70
+ COPY . .
71
+
72
+ EXPOSE 7860
73
+
74
+ CMD ["python", "app.py"]
75
+ ```
76
+
77
+ 6. **Upload Files**
78
+ - Upload all files to your Space repository
79
+ - Or connect your GitHub repository for automatic synchronization
80
+
81
+ 7. **Wait for Build**
82
+ - Hugging Face will automatically build and deploy your application
83
+ - This may take several minutes due to the size of OCR dependencies
84
+
85
+ ## How to Use
86
+
87
+ ### PDF OCR Conversion:
88
+ 1. Navigate to the "PDF OCR Converter" tab
89
+ 2. Upload your PDF file
90
+ 3. Click "Process PDF with OCR"
91
+ 4. Wait for processing to complete
92
+ 5. Download the OCRed PDF when finished
93
+
94
+ ### Excel to CSV Conversion:
95
+ 1. Navigate to the "Excel to CSV Converter" tab
96
+ 2. Upload your Excel file (.xlsx or .xls)
97
+ 3. Click "Convert to CSV"
98
+ 4. Download the converted CSV file when finished
99
+
100
+ ## Technical Details
101
+
102
+ The application uses:
103
+ - **ocrmypdf**: For PDF OCR processing with parameters: `--force-ocr --deskew --rotate-pages --oversample 300`
104
+ - **pandas**: For fast Excel to CSV conversion with optimized settings
105
+ - **Gradio**: For the user interface
106
+ - **openpyxl**: For Excel file processing
107
+
108
+ ## Requirements
109
+
110
+ - Python 3.8+
111
+ - System dependencies: ocrmypdf, tesseract-ocr, poppler-utils
112
+
113
+ ## Local Development
114
+
115
+ To run locally:
116
+ ```bash
117
+ pip install -r requirements.txt
118
+ python app.py
119
+ ```
120
+
121
+ Then visit `http://localhost:7860` in your browser.
OCR Extracter web app - for pdf/app.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import ocrmypdf
3
+ import pandas as pd
4
+ import openpyxl
5
+ import tempfile
6
+ import os
7
+ import uuid
8
+ from werkzeug.utils import secure_filename
9
+
10
+ def ocr_pdf(input_pdf):
11
+ """Process PDF with OCR using ocrmypdf"""
12
+ if input_pdf is None:
13
+ return None, "Please upload a PDF file"
14
+
15
+ with tempfile.NamedTemporaryFile(suffix='.pdf', delete=False) as temp_output:
16
+ try:
17
+ # Process with ocrmypdf using the parameters you specified
18
+ ocrmypdf.ocr(
19
+ input_pdf.name,
20
+ temp_output.name,
21
+ force_ocr=True,
22
+ deskew=True,
23
+ rotate_pages=True,
24
+ oversample=300
25
+ )
26
+ return temp_output.name, "PDF processed successfully!"
27
+ except Exception as e:
28
+ return None, f"Error processing PDF: {str(e)}"
29
+
30
+ def convert_excel_to_csv(input_excel):
31
+ """Convert Excel file to CSV"""
32
+ if input_excel is None:
33
+ return None, "Please upload an Excel file"
34
+
35
+ try:
36
+ # Read Excel file with optimizations for speed
37
+ df = pd.read_excel(
38
+ input_excel.name,
39
+ engine="openpyxl",
40
+ dtype=str, # Big speed boost
41
+ parse_dates=False, # No date parsing
42
+ keep_default_na=False
43
+ )
44
+
45
+ # Create temporary CSV file
46
+ with tempfile.NamedTemporaryFile(mode='w', suffix='.csv', delete=False, newline='', encoding='utf-8') as temp_csv:
47
+ df.to_csv(temp_csv.name, index=False, encoding="utf-8")
48
+ return temp_csv.name, "Excel converted to CSV successfully!"
49
+ except Exception as e:
50
+ return None, f"Error converting Excel: {str(e)}"
51
+
52
+ # Create Gradio interface with tabs
53
+ with gr.Blocks(title="Document Converter Pro", theme=gr.themes.Soft()) as demo:
54
+ gr.Markdown("# 📄 Document Converter Pro")
55
+ gr.Markdown("Convert your documents with ease using our powerful online tools")
56
+
57
+ with gr.Tabs():
58
+ with gr.TabItem("PDF OCR Converter"):
59
+ gr.Markdown("### Convert scanned PDFs to searchable, text-based PDFs")
60
+ with gr.Row():
61
+ with gr.Column():
62
+ pdf_input = gr.File(label="Upload PDF", file_types=[".pdf"])
63
+ pdf_btn = gr.Button("Process PDF with OCR")
64
+ with gr.Column():
65
+ pdf_output = gr.File(label="Download OCRed PDF")
66
+ pdf_status = gr.Textbox(label="Status", interactive=False)
67
+
68
+ pdf_btn.click(
69
+ fn=ocr_pdf,
70
+ inputs=pdf_input,
71
+ outputs=[pdf_output, pdf_status]
72
+ )
73
+
74
+ with gr.TabItem("Excel to CSV Converter"):
75
+ gr.Markdown("### Convert Excel files to CSV format quickly and efficiently")
76
+ with gr.Row():
77
+ with gr.Column():
78
+ excel_input = gr.File(label="Upload Excel", file_types=[".xlsx", ".xls"])
79
+ excel_btn = gr.Button("Convert to CSV")
80
+ with gr.Column():
81
+ excel_output = gr.File(label="Download CSV")
82
+ excel_status = gr.Textbox(label="Status", interactive=False)
83
+
84
+ excel_btn.click(
85
+ fn=convert_excel_to_csv,
86
+ inputs=excel_input,
87
+ outputs=[excel_output, excel_status]
88
+ )
89
+
90
+ if __name__ == "__main__":
91
+ demo.launch(server_port=int(os.getenv("PORT", 7860)))
OCR Extracter web app - for pdf/main.py ADDED
@@ -0,0 +1,342 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, render_template, request, send_file, redirect, url_for, flash, jsonify
2
+ import os
3
+ import subprocess
4
+ import tempfile
5
+ import uuid
6
+ from werkzeug.utils import secure_filename
7
+ import threading
8
+ import time
9
+
10
+ app = Flask(__name__)
11
+ app.secret_key = 'your-secret-key-here'
12
+
13
+ # Import for Excel processing
14
+ import pandas as pd
15
+ import openpyxl
16
+
17
+ # Configuration
18
+ UPLOAD_FOLDER = 'uploads'
19
+ PROCESSED_FOLDER = 'processed'
20
+ ALLOWED_EXTENSIONS = {'pdf'}
21
+
22
+ app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
23
+ app.config['PROCESSED_FOLDER'] = PROCESSED_FOLDER
24
+
25
+ # Create necessary directories
26
+ os.makedirs(UPLOAD_FOLDER, exist_ok=True)
27
+ os.makedirs(PROCESSED_FOLDER, exist_ok=True)
28
+
29
+ # Global dictionary to store processing status
30
+ processing_status = {}
31
+
32
+ def allowed_file(filename):
33
+ """Check if the uploaded file has an allowed extension"""
34
+ return '.' in filename and \
35
+ filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
36
+
37
+
38
+ def validate_pdf_file(file_path):
39
+ """Validate that the uploaded file is actually a PDF"""
40
+ try:
41
+ # Check if file exists and has PDF header
42
+ if not os.path.exists(file_path):
43
+ return False, "File does not exist"
44
+
45
+ # Read first few bytes to check PDF header
46
+ with open(file_path, 'rb') as f:
47
+ header = f.read(4)
48
+ if header != b'%PDF':
49
+ return False, "File is not a valid PDF"
50
+
51
+ # Check file size (max 50MB)
52
+ file_size = os.path.getsize(file_path)
53
+ max_size = 50 * 1024 * 1024 # 50MB
54
+ if file_size > max_size:
55
+ return False, f"File size too large. Max size is 50MB, got {file_size / (1024*1024):.1f}MB"
56
+
57
+ return True, "Valid PDF"
58
+ except Exception as e:
59
+ return False, f"Error validating PDF: {str(e)}"
60
+
61
+ def process_pdf_with_ocr(input_path, output_path, job_id=None):
62
+ """Process PDF with OCR using ocrmypdf"""
63
+ try:
64
+ # Using the ocrmypdf command similar to what was provided
65
+ cmd = [
66
+ 'ocrmypdf',
67
+ '--force-ocr',
68
+ '--deskew',
69
+ '--rotate-pages',
70
+ '--oversample', '300',
71
+ input_path,
72
+ output_path
73
+ ]
74
+
75
+ import logging
76
+ logging.basicConfig(level=logging.INFO)
77
+ logger = logging.getLogger(__name__)
78
+
79
+ logger.info(f"Executing OCR command: {' '.join(cmd)}")
80
+
81
+ # Run the command and capture output in real-time
82
+ result = subprocess.run(
83
+ cmd,
84
+ capture_output=True,
85
+ text=True,
86
+ timeout=600 # 10 minute timeout
87
+ )
88
+
89
+ logger.info(f"OCR process completed with return code: {result.returncode}")
90
+ if result.stdout:
91
+ logger.info(f"OCR stdout: {result.stdout}")
92
+ if result.stderr:
93
+ logger.info(f"OCR stderr: {result.stderr}")
94
+
95
+ if result.returncode != 0:
96
+ raise Exception(f"OCR processing failed with return code {result.returncode}: {result.stderr}")
97
+
98
+ return True
99
+ except subprocess.TimeoutExpired:
100
+ raise Exception("Processing timed out after 10 minutes")
101
+ except Exception as e:
102
+ import logging
103
+ logging.basicConfig(level=logging.INFO)
104
+ logger = logging.getLogger(__name__)
105
+ logger.error(f"OCR processing error: {str(e)}")
106
+ raise e
107
+
108
+ # Main routes
109
+ @app.route('/')
110
+ def index():
111
+ """Main page route"""
112
+ return render_template('index.html')
113
+
114
+ @app.route('/pdf-ocr')
115
+ def pdf_ocr():
116
+ """PDF OCR converter page route"""
117
+ return render_template('pdf_ocr.html')
118
+
119
+ @app.route('/excel-to-csv')
120
+ def excel_to_csv():
121
+ """Excel to CSV converter page route"""
122
+ return render_template('excel_to_csv.html')
123
+
124
+ # Routes for PDF OCR functionality
125
+ @app.route('/upload', methods=['POST'])
126
+ def upload_file():
127
+ """Handle PDF file upload"""
128
+ if 'pdf_file' not in request.files:
129
+ return jsonify({'success': False, 'message': 'No file selected'})
130
+
131
+ file = request.files['pdf_file']
132
+
133
+ if file.filename == '':
134
+ return jsonify({'success': False, 'message': 'No file selected'})
135
+
136
+ if file and allowed_file(file.filename):
137
+ filename = secure_filename(file.filename)
138
+ unique_filename = f"{uuid.uuid4()}_{filename}"
139
+ filepath = os.path.join(app.config['UPLOAD_FOLDER'], unique_filename)
140
+ file.save(filepath)
141
+
142
+ # Validate the PDF file
143
+ is_valid, validation_msg = validate_pdf_file(filepath)
144
+ if not is_valid:
145
+ # Clean up invalid file
146
+ try:
147
+ os.remove(filepath)
148
+ except:
149
+ pass # Ignore cleanup errors
150
+ return jsonify({'success': False, 'message': f'Invalid PDF file: {validation_msg}'})
151
+
152
+ # Generate unique output filename
153
+ output_filename = f"ocr_{unique_filename}"
154
+ output_path = os.path.join(app.config['PROCESSED_FOLDER'], output_filename)
155
+
156
+ # Store processing status
157
+ job_id = str(uuid.uuid4())
158
+ processing_status[job_id] = {
159
+ 'status': 'processing',
160
+ 'input_file': filepath,
161
+ 'output_file': output_path,
162
+ 'progress': 0
163
+ }
164
+
165
+ # Start processing in a separate thread
166
+ thread = threading.Thread(target=process_file_thread, args=(job_id,))
167
+ thread.start()
168
+
169
+ return jsonify({
170
+ 'success': True,
171
+ 'job_id': job_id,
172
+ 'message': 'File uploaded successfully. Processing started...'
173
+ })
174
+ else:
175
+ return jsonify({'success': False, 'message': 'Invalid file type. Please upload a PDF.'})
176
+
177
+ def process_file_thread(job_id):
178
+ """Process file in a separate thread"""
179
+ status = processing_status.get(job_id)
180
+ if not status:
181
+ return
182
+
183
+ try:
184
+ # Update progress
185
+ processing_status[job_id]['progress'] = 5
186
+ time.sleep(0.5) # Brief pause
187
+
188
+ # Estimate progress based on file size
189
+ input_size = os.path.getsize(status['input_file'])
190
+ estimated_pages = max(1, input_size // (100 * 1024)) # Rough estimate: 1 page per 100KB
191
+
192
+ # Update progress incrementally
193
+ base_progress = 5
194
+ progress_increment = (90 - base_progress) / estimated_pages # 90% total for processing
195
+
196
+ for page in range(estimated_pages):
197
+ # In a real implementation, we would track actual OCR progress
198
+ # Here we simulate progress based on estimated pages
199
+ simulated_progress = int(base_progress + (page * progress_increment))
200
+ processing_status[job_id]['progress'] = min(simulated_progress, 95)
201
+ time.sleep(0.1) # Small delay to simulate processing time per page
202
+
203
+ # Perform OCR processing
204
+ process_pdf_with_ocr(status['input_file'], status['output_file'], job_id)
205
+
206
+ # Update status when complete
207
+ processing_status[job_id]['status'] = 'completed'
208
+ processing_status[job_id]['progress'] = 100
209
+ except Exception as e:
210
+ processing_status[job_id]['status'] = 'failed'
211
+ processing_status[job_id]['error'] = str(e)
212
+ processing_status[job_id]['progress'] = 0
213
+
214
+ # Clean up failed output file if it exists
215
+ try:
216
+ if os.path.exists(status['output_file']):
217
+ os.remove(status['output_file'])
218
+ except:
219
+ pass # Ignore cleanup errors
220
+
221
+ @app.route('/status/<job_id>')
222
+ def get_status(job_id):
223
+ """Get processing status for a job"""
224
+ if job_id in processing_status:
225
+ return jsonify(processing_status[job_id])
226
+ else:
227
+ return jsonify({'status': 'not_found'})
228
+
229
+ @app.route('/download/<job_id>')
230
+ def download_file(job_id):
231
+ """Download processed file"""
232
+ if job_id in processing_status:
233
+ status = processing_status[job_id]
234
+ if status['status'] == 'completed':
235
+ return send_file(status['output_file'], as_attachment=True,
236
+ download_name=f"ocr_processed_{os.path.basename(status['output_file'])}")
237
+ else:
238
+ flash('File is not ready for download')
239
+ return redirect(url_for('index'))
240
+ else:
241
+ flash('Invalid job ID')
242
+ return redirect(url_for('index'))
243
+
244
+ @app.route('/cleanup', methods=['POST'])
245
+ def cleanup():
246
+ """Clean up temporary files"""
247
+ # Clean up uploaded files older than 1 hour
248
+ current_time = time.time()
249
+ for filename in os.listdir(app.config['UPLOAD_FOLDER']):
250
+ file_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
251
+ if os.path.isfile(file_path):
252
+ if current_time - os.path.getmtime(file_path) > 3600: # 1 hour
253
+ os.remove(file_path)
254
+
255
+ # Clean up processed files older than 1 hour
256
+ for filename in os.listdir(app.config['PROCESSED_FOLDER']):
257
+ file_path = os.path.join(app.config['PROCESSED_FOLDER'], filename)
258
+ if os.path.isfile(file_path):
259
+ if current_time - os.path.getmtime(file_path) > 3600: # 1 hour
260
+ os.remove(file_path)
261
+
262
+ # Clean up old processing statuses
263
+ expired_jobs = []
264
+ for job_id, status in processing_status.items():
265
+ if status['status'] == 'completed' and current_time - os.path.getmtime(status['output_file']) > 3600:
266
+ expired_jobs.append(job_id)
267
+
268
+ for job_id in expired_jobs:
269
+ del processing_status[job_id]
270
+
271
+ return jsonify({'success': True, 'message': 'Cleanup completed'})
272
+
273
+
274
+ # Routes for Excel to CSV functionality
275
+ @app.route('/convert-excel', methods=['POST'])
276
+ def convert_excel_to_csv():
277
+ """Convert Excel files to CSV"""
278
+ try:
279
+ if 'excel_file' not in request.files:
280
+ return jsonify({'success': False, 'message': 'No file selected'})
281
+
282
+ file = request.files['excel_file']
283
+
284
+ if file.filename == '':
285
+ return jsonify({'success': False, 'message': 'No file selected'})
286
+
287
+ if file and file.filename.lower().endswith(('.xlsx', '.xls')):
288
+ filename = secure_filename(file.filename)
289
+ unique_filename = f"{uuid.uuid4()}_{filename}"
290
+ filepath = os.path.join(app.config['UPLOAD_FOLDER'], unique_filename)
291
+ file.save(filepath)
292
+
293
+ # Convert Excel to CSV
294
+ output_filename = f"{os.path.splitext(unique_filename)[0]}.csv"
295
+ output_path = os.path.join(app.config['PROCESSED_FOLDER'], output_filename)
296
+
297
+ # Process Excel file to CSV
298
+ df = pd.read_excel(
299
+ filepath,
300
+ engine="openpyxl",
301
+ dtype=str,
302
+ parse_dates=False,
303
+ keep_default_na=False
304
+ )
305
+
306
+ df.to_csv(output_path, index=False, encoding="utf-8")
307
+
308
+ # Clean up uploaded file
309
+ try:
310
+ os.remove(filepath)
311
+ except:
312
+ pass # Ignore cleanup errors
313
+
314
+ return jsonify({
315
+ 'success': True,
316
+ 'output_filename': output_filename,
317
+ 'message': 'File converted successfully!'
318
+ })
319
+ else:
320
+ return jsonify({'success': False, 'message': 'Invalid file type. Please upload an Excel file (.xlsx or .xls)'})
321
+
322
+ except Exception as e:
323
+ return jsonify({'success': False, 'message': f'Conversion failed: {str(e)}'})
324
+
325
+ @app.route('/download-csv/<filename>')
326
+ def download_csv(filename):
327
+ """Download converted CSV file"""
328
+ try:
329
+ file_path = os.path.join(app.config['PROCESSED_FOLDER'], filename)
330
+ if os.path.exists(file_path):
331
+ return send_file(file_path, as_attachment=True,
332
+ download_name=f"converted_{filename}")
333
+ else:
334
+ flash('File not found')
335
+ return redirect(url_for('excel_to_csv'))
336
+ except Exception as e:
337
+ flash(f'Download failed: {str(e)}')
338
+ return redirect(url_for('excel_to_csv'))
339
+
340
+
341
+ if __name__ == '__main__':
342
+ app.run(debug=True, host='0.0.0.0', port=5000)
OCR Extracter web app - for pdf/processed/ocr_6bf37a2b-75cf-4698-afaf-d6edeeecdb55_sample_report.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0571f51e8a190df2520e9ce13c20f70481a796510b76da73ef62cbcb3edcf996
3
+ size 1268012
OCR Extracter web app - for pdf/processed/ocr_e9869372-a4ab-4e20-82b6-09ce6180bb97_Aug.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7b4a99c21eba23a59c942d14d61fd89e05dd44d7cfc80932df40e8d55b89ad2c
3
+ size 954234
OCR Extracter web app - for pdf/requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ Flask==2.3.3
2
+ Werkzeug==2.3.7
3
+ pandas==2.2.2
4
+ openpyxl==3.1.2
5
+ gradio==4.28.3
6
+ ocrmypdf==16.11.1
OCR Extracter web app - for pdf/templates/excel_to_csv.html ADDED
@@ -0,0 +1,382 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Excel to CSV Converter</title>
7
+ <style>
8
+ * {
9
+ margin: 0;
10
+ padding: 0;
11
+ box-sizing: border-box;
12
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
13
+ }
14
+
15
+ body {
16
+ background: linear-gradient(135deg, #36d1dc 0%, #5b86e5 100%);
17
+ min-height: 100vh;
18
+ display: flex;
19
+ flex-direction: column;
20
+ }
21
+
22
+ .navbar {
23
+ background: rgba(255, 255, 255, 0.95);
24
+ backdrop-filter: blur(10px);
25
+ padding: 15px 30px;
26
+ display: flex;
27
+ justify-content: space-between;
28
+ align-items: center;
29
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
30
+ position: sticky;
31
+ top: 0;
32
+ z-index: 100;
33
+ }
34
+
35
+ .logo {
36
+ font-size: 1.8em;
37
+ font-weight: bold;
38
+ color: #36d1dc;
39
+ text-decoration: none;
40
+ }
41
+
42
+ .nav-links {
43
+ display: flex;
44
+ gap: 20px;
45
+ }
46
+
47
+ .nav-link {
48
+ text-decoration: none;
49
+ color: #333;
50
+ padding: 8px 16px;
51
+ border-radius: 20px;
52
+ transition: all 0.3s ease;
53
+ font-weight: 500;
54
+ }
55
+
56
+ .nav-link:hover, .nav-link.active {
57
+ background: linear-gradient(135deg, #36d1dc 0%, #5b86e5 100%);
58
+ color: white;
59
+ }
60
+
61
+ .container {
62
+ flex: 1;
63
+ display: flex;
64
+ justify-content: center;
65
+ align-items: center;
66
+ padding: 20px;
67
+ background: linear-gradient(135deg, #36d1dc 0%, #5b86e5 100%);
68
+ }
69
+
70
+ .content {
71
+ background: rgba(255, 255, 255, 0.95);
72
+ backdrop-filter: blur(10px);
73
+ border-radius: 20px;
74
+ box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
75
+ padding: 40px;
76
+ width: 100%;
77
+ max-width: 600px;
78
+ text-align: center;
79
+ }
80
+
81
+ h1 {
82
+ color: #333;
83
+ margin-bottom: 10px;
84
+ font-size: 2.5em;
85
+ text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
86
+ }
87
+
88
+ .subtitle {
89
+ color: #666;
90
+ margin-bottom: 30px;
91
+ font-size: 1.1em;
92
+ }
93
+
94
+ .upload-area {
95
+ border: 3px dashed #36d1dc;
96
+ border-radius: 15px;
97
+ padding: 40px 20px;
98
+ margin: 20px 0;
99
+ cursor: pointer;
100
+ transition: all 0.3s ease;
101
+ background: rgba(54, 209, 220, 0.05);
102
+ }
103
+
104
+ .upload-area:hover, .upload-area.dragover {
105
+ background: rgba(54, 209, 220, 0.1);
106
+ border-color: #5b86e5;
107
+ }
108
+
109
+ .upload-icon {
110
+ font-size: 4em;
111
+ color: #36d1dc;
112
+ margin-bottom: 15px;
113
+ }
114
+
115
+ .upload-text {
116
+ color: #666;
117
+ margin-bottom: 15px;
118
+ }
119
+
120
+ .file-input {
121
+ display: none;
122
+ }
123
+
124
+ .btn {
125
+ background: linear-gradient(135deg, #36d1dc 0%, #5b86e5 100%);
126
+ color: white;
127
+ border: none;
128
+ padding: 12px 30px;
129
+ border-radius: 25px;
130
+ cursor: pointer;
131
+ font-size: 16px;
132
+ font-weight: 600;
133
+ transition: all 0.3s ease;
134
+ margin: 10px 5px;
135
+ box-shadow: 0 4px 15px rgba(54, 209, 220, 0.3);
136
+ }
137
+
138
+ .btn:hover {
139
+ transform: translateY(-2px);
140
+ box-shadow: 0 6px 20px rgba(54, 209, 220, 0.4);
141
+ }
142
+
143
+ .btn:disabled {
144
+ opacity: 0.6;
145
+ cursor: not-allowed;
146
+ transform: none;
147
+ }
148
+
149
+ .btn-secondary {
150
+ background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
151
+ }
152
+
153
+ .result-container {
154
+ margin: 20px 0;
155
+ display: none;
156
+ }
157
+
158
+ .result-message {
159
+ padding: 15px;
160
+ border-radius: 10px;
161
+ margin-bottom: 15px;
162
+ text-align: left;
163
+ }
164
+
165
+ .success {
166
+ background-color: #d4edda;
167
+ color: #155724;
168
+ border: 1px solid #c3e6cb;
169
+ }
170
+
171
+ .error {
172
+ background-color: #f8d7da;
173
+ color: #721c24;
174
+ border: 1px solid #f5c6cb;
175
+ }
176
+
177
+ .floating-element {
178
+ position: absolute;
179
+ width: 100px;
180
+ height: 100px;
181
+ background: rgba(255, 255, 255, 0.1);
182
+ border-radius: 50%;
183
+ animation: float 6s ease-in-out infinite;
184
+ z-index: -1;
185
+ }
186
+
187
+ .floating-element:nth-child(1) {
188
+ top: 10%;
189
+ left: 10%;
190
+ animation-delay: 0s;
191
+ }
192
+
193
+ .floating-element:nth-child(2) {
194
+ top: 20%;
195
+ right: 10%;
196
+ animation-delay: 2s;
197
+ width: 80px;
198
+ height: 80px;
199
+ }
200
+
201
+ .floating-element:nth-child(3) {
202
+ bottom: 10%;
203
+ left: 20%;
204
+ animation-delay: 4s;
205
+ width: 60px;
206
+ height: 60px;
207
+ }
208
+
209
+ @keyframes float {
210
+ 0%, 100% { transform: translateY(0px) rotate(0deg); }
211
+ 50% { transform: translateY(-20px) rotate(180deg); }
212
+ }
213
+
214
+ @media (max-width: 768px) {
215
+ .content {
216
+ padding: 20px;
217
+ margin: 10px;
218
+ }
219
+
220
+ h1 {
221
+ font-size: 2em;
222
+ }
223
+ }
224
+ </style>
225
+ </head>
226
+ <body>
227
+ <!-- Floating elements for visual effect -->
228
+ <div class="floating-element"></div>
229
+ <div class="floating-element"></div>
230
+ <div class="floating-element"></div>
231
+
232
+ <nav class="navbar">
233
+ <a href="/" class="logo">DocConverter Pro</a>
234
+ <div class="nav-links">
235
+ <a href="/" class="nav-link">Home</a>
236
+ <a href="/pdf-ocr" class="nav-link">PDF OCR</a>
237
+ <a href="/excel-to-csv" class="nav-link active">Excel to CSV</a>
238
+ </div>
239
+ </nav>
240
+
241
+ <div class="container">
242
+ <div class="content">
243
+ <h1>Excel to CSV Converter</h1>
244
+ <p class="subtitle">Convert Excel files to CSV format quickly and efficiently</p>
245
+
246
+ <div class="upload-area" id="uploadArea">
247
+ <div class="upload-icon">📊</div>
248
+ <p class="upload-text">Drag & drop your Excel file here or click to browse</p>
249
+ <p class="upload-subtext">Supports: .xlsx and .xls files</p>
250
+ <input type="file" id="fileInput" class="file-input" accept=".xlsx,.xls">
251
+ </div>
252
+
253
+ <button id="convertBtn" class="btn">Convert to CSV</button>
254
+
255
+ <div class="result-container" id="resultContainer">
256
+ <div id="resultMessage" class="result-message"></div>
257
+ <button id="downloadBtn" class="btn" style="display:none;">Download CSV</button>
258
+ <button id="newConversionBtn" class="btn btn-secondary">New Conversion</button>
259
+ </div>
260
+ </div>
261
+ </div>
262
+
263
+ <script>
264
+ document.addEventListener('DOMContentLoaded', function() {
265
+ const fileInput = document.getElementById('fileInput');
266
+ const uploadArea = document.getElementById('uploadArea');
267
+ const convertBtn = document.getElementById('convertBtn');
268
+ const resultContainer = document.getElementById('resultContainer');
269
+ const resultMessage = document.getElementById('resultMessage');
270
+ const downloadBtn = document.getElementById('downloadBtn');
271
+ const newConversionBtn = document.getElementById('newConversionBtn');
272
+
273
+ let currentOutputFilename = null;
274
+
275
+ // Click on upload area triggers file input
276
+ uploadArea.addEventListener('click', () => {
277
+ fileInput.click();
278
+ });
279
+
280
+ // Drag and drop functionality
281
+ uploadArea.addEventListener('dragover', (e) => {
282
+ e.preventDefault();
283
+ uploadArea.classList.add('dragover');
284
+ });
285
+
286
+ uploadArea.addEventListener('dragleave', () => {
287
+ uploadArea.classList.remove('dragover');
288
+ });
289
+
290
+ uploadArea.addEventListener('drop', (e) => {
291
+ e.preventDefault();
292
+ uploadArea.classList.remove('dragover');
293
+
294
+ if (e.dataTransfer.files.length) {
295
+ fileInput.files = e.dataTransfer.files;
296
+ updateFileNameDisplay();
297
+ }
298
+ });
299
+
300
+ // Handle file selection
301
+ fileInput.addEventListener('change', updateFileNameDisplay);
302
+
303
+ function updateFileNameDisplay() {
304
+ if (fileInput.files.length > 0) {
305
+ const fileName = fileInput.files[0].name;
306
+ uploadArea.querySelector('.upload-text').textContent = `Selected: ${fileName}`;
307
+ }
308
+ }
309
+
310
+ // Convert button click handler
311
+ convertBtn.addEventListener('click', () => {
312
+ if (!fileInput.files.length) {
313
+ alert('Please select an Excel file first.');
314
+ return;
315
+ }
316
+
317
+ const file = fileInput.files[0];
318
+ const fileExt = file.name.toLowerCase().split('.').pop();
319
+ if (fileExt !== 'xlsx' && fileExt !== 'xls') {
320
+ alert('Please select an Excel file (.xlsx or .xls).');
321
+ return;
322
+ }
323
+
324
+ convertFile(file);
325
+ });
326
+
327
+ // Convert file function
328
+ async function convertFile(file) {
329
+ const formData = new FormData();
330
+ formData.append('excel_file', file);
331
+
332
+ try {
333
+ convertBtn.disabled = true;
334
+
335
+ const response = await fetch('/convert-excel', {
336
+ method: 'POST',
337
+ body: formData
338
+ });
339
+
340
+ const result = await response.json();
341
+
342
+ resultContainer.style.display = 'block';
343
+
344
+ if (result.success) {
345
+ currentOutputFilename = result.output_filename;
346
+ resultMessage.textContent = result.message;
347
+ resultMessage.className = 'result-message success';
348
+
349
+ // Enable download button
350
+ downloadBtn.onclick = () => {
351
+ window.location.href = `/download-csv/${currentOutputFilename}`;
352
+ };
353
+ downloadBtn.style.display = 'inline-block';
354
+ } else {
355
+ resultMessage.textContent = result.message || 'Conversion failed';
356
+ resultMessage.className = 'result-message error';
357
+ downloadBtn.style.display = 'none';
358
+ }
359
+ } catch (error) {
360
+ console.error('Conversion error:', error);
361
+ resultMessage.textContent = 'Conversion failed: ' + error.message;
362
+ resultMessage.className = 'result-message error';
363
+ resultContainer.style.display = 'block';
364
+ downloadBtn.style.display = 'none';
365
+ } finally {
366
+ convertBtn.disabled = false;
367
+ }
368
+ }
369
+
370
+ // New conversion button
371
+ newConversionBtn.addEventListener('click', () => {
372
+ // Reset form
373
+ fileInput.value = '';
374
+ uploadArea.querySelector('.upload-text').textContent = 'Drag & drop your Excel file here or click to browse';
375
+ resultContainer.style.display = 'none';
376
+ convertBtn.disabled = false;
377
+ currentOutputFilename = null;
378
+ });
379
+ });
380
+ </script>
381
+ </body>
382
+ </html>
OCR Extracter web app - for pdf/templates/index.html ADDED
@@ -0,0 +1,238 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Document Conversion Tools</title>
7
+ <style>
8
+ * {
9
+ margin: 0;
10
+ padding: 0;
11
+ box-sizing: border-box;
12
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
13
+ }
14
+
15
+ body {
16
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
17
+ min-height: 100vh;
18
+ display: flex;
19
+ flex-direction: column;
20
+ }
21
+
22
+ .navbar {
23
+ background: rgba(255, 255, 255, 0.95);
24
+ backdrop-filter: blur(10px);
25
+ padding: 15px 30px;
26
+ display: flex;
27
+ justify-content: space-between;
28
+ align-items: center;
29
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
30
+ position: sticky;
31
+ top: 0;
32
+ z-index: 100;
33
+ }
34
+
35
+ .logo {
36
+ font-size: 1.8em;
37
+ font-weight: bold;
38
+ color: #667eea;
39
+ text-decoration: none;
40
+ }
41
+
42
+ .nav-links {
43
+ display: flex;
44
+ gap: 20px;
45
+ }
46
+
47
+ .nav-link {
48
+ text-decoration: none;
49
+ color: #333;
50
+ padding: 8px 16px;
51
+ border-radius: 20px;
52
+ transition: all 0.3s ease;
53
+ font-weight: 500;
54
+ }
55
+
56
+ .nav-link:hover, .nav-link.active {
57
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
58
+ color: white;
59
+ }
60
+
61
+ .hero {
62
+ flex: 1;
63
+ display: flex;
64
+ flex-direction: column;
65
+ justify-content: center;
66
+ align-items: center;
67
+ text-align: center;
68
+ padding: 40px;
69
+ color: white;
70
+ }
71
+
72
+ h1 {
73
+ font-size: 3em;
74
+ margin-bottom: 20px;
75
+ text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
76
+ }
77
+
78
+ .subtitle {
79
+ font-size: 1.2em;
80
+ margin-bottom: 40px;
81
+ max-width: 600px;
82
+ opacity: 0.9;
83
+ }
84
+
85
+ .services-grid {
86
+ display: grid;
87
+ grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
88
+ gap: 30px;
89
+ width: 90%;
90
+ max-width: 1200px;
91
+ margin: 0 auto;
92
+ }
93
+
94
+ .service-card {
95
+ background: rgba(255, 255, 255, 0.95);
96
+ backdrop-filter: blur(10px);
97
+ border-radius: 20px;
98
+ padding: 30px;
99
+ text-align: center;
100
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
101
+ transition: all 0.3s ease;
102
+ cursor: pointer;
103
+ }
104
+
105
+ .service-card:hover {
106
+ transform: translateY(-10px);
107
+ box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
108
+ }
109
+
110
+ .service-icon {
111
+ font-size: 3em;
112
+ margin-bottom: 20px;
113
+ color: #667eea;
114
+ }
115
+
116
+ .service-title {
117
+ font-size: 1.5em;
118
+ color: #333;
119
+ margin-bottom: 15px;
120
+ }
121
+
122
+ .service-description {
123
+ color: #666;
124
+ margin-bottom: 20px;
125
+ line-height: 1.6;
126
+ }
127
+
128
+ .btn {
129
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
130
+ color: white;
131
+ border: none;
132
+ padding: 12px 30px;
133
+ border-radius: 25px;
134
+ cursor: pointer;
135
+ font-size: 16px;
136
+ font-weight: 600;
137
+ transition: all 0.3s ease;
138
+ text-decoration: none;
139
+ display: inline-block;
140
+ box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
141
+ }
142
+
143
+ .btn:hover {
144
+ transform: translateY(-2px);
145
+ box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
146
+ }
147
+
148
+ .floating-element {
149
+ position: absolute;
150
+ width: 100px;
151
+ height: 100px;
152
+ background: rgba(255, 255, 255, 0.1);
153
+ border-radius: 50%;
154
+ animation: float 6s ease-in-out infinite;
155
+ z-index: -1;
156
+ }
157
+
158
+ .floating-element:nth-child(1) {
159
+ top: 10%;
160
+ left: 10%;
161
+ animation-delay: 0s;
162
+ }
163
+
164
+ .floating-element:nth-child(2) {
165
+ top: 20%;
166
+ right: 10%;
167
+ animation-delay: 2s;
168
+ width: 80px;
169
+ height: 80px;
170
+ }
171
+
172
+ .floating-element:nth-child(3) {
173
+ bottom: 10%;
174
+ left: 20%;
175
+ animation-delay: 4s;
176
+ width: 60px;
177
+ height: 60px;
178
+ }
179
+
180
+ @keyframes float {
181
+ 0%, 100% { transform: translateY(0px) rotate(0deg); }
182
+ 50% { transform: translateY(-20px) rotate(180deg); }
183
+ }
184
+
185
+ @media (max-width: 768px) {
186
+ .navbar {
187
+ flex-direction: column;
188
+ gap: 15px;
189
+ }
190
+
191
+ .nav-links {
192
+ flex-wrap: wrap;
193
+ justify-content: center;
194
+ }
195
+
196
+ h1 {
197
+ font-size: 2.2em;
198
+ }
199
+ }
200
+ </style>
201
+ </head>
202
+ <body>
203
+ <!-- Floating elements for visual effect -->
204
+ <div class="floating-element"></div>
205
+ <div class="floating-element"></div>
206
+ <div class="floating-element"></div>
207
+
208
+ <nav class="navbar">
209
+ <a href="/" class="logo">DocConverter Pro</a>
210
+ <div class="nav-links">
211
+ <a href="/" class="nav-link active">Home</a>
212
+ <a href="/pdf-ocr" class="nav-link">PDF OCR</a>
213
+ <a href="/excel-to-csv" class="nav-link">Excel to CSV</a>
214
+ </div>
215
+ </nav>
216
+
217
+ <section class="hero">
218
+ <h1>Document Conversion Tools</h1>
219
+ <p class="subtitle">Convert your documents with ease using our powerful online tools</p>
220
+
221
+ <div class="services-grid">
222
+ <div class="service-card" onclick="window.location.href='/pdf-ocr'">
223
+ <div class="service-icon">📄</div>
224
+ <h3 class="service-title">PDF OCR Converter</h3>
225
+ <p class="service-description">Convert scanned PDFs to searchable, text-based PDFs using advanced OCR technology</p>
226
+ <a href="/pdf-ocr" class="btn">Convert PDF</a>
227
+ </div>
228
+
229
+ <div class="service-card" onclick="window.location.href='/excel-to-csv'">
230
+ <div class="service-icon">📊</div>
231
+ <h3 class="service-title">Excel to CSV Converter</h3>
232
+ <p class="service-description">Convert Excel files to CSV format quickly and efficiently</p>
233
+ <a href="/excel-to-csv" class="btn">Convert Excel</a>
234
+ </div>
235
+ </div>
236
+ </section>
237
+ </body>
238
+ </html>
OCR Extracter web app - for pdf/templates/pdf_ocr.html ADDED
@@ -0,0 +1,469 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>PDF to OCR Converter</title>
7
+ <style>
8
+ * {
9
+ margin: 0;
10
+ padding: 0;
11
+ box-sizing: border-box;
12
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
13
+ }
14
+
15
+ body {
16
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
17
+ min-height: 100vh;
18
+ display: flex;
19
+ flex-direction: column;
20
+ }
21
+
22
+ .navbar {
23
+ background: rgba(255, 255, 255, 0.95);
24
+ backdrop-filter: blur(10px);
25
+ padding: 15px 30px;
26
+ display: flex;
27
+ justify-content: space-between;
28
+ align-items: center;
29
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
30
+ position: sticky;
31
+ top: 0;
32
+ z-index: 100;
33
+ }
34
+
35
+ .logo {
36
+ font-size: 1.8em;
37
+ font-weight: bold;
38
+ color: #667eea;
39
+ text-decoration: none;
40
+ }
41
+
42
+ .nav-links {
43
+ display: flex;
44
+ gap: 20px;
45
+ }
46
+
47
+ .nav-link {
48
+ text-decoration: none;
49
+ color: #333;
50
+ padding: 8px 16px;
51
+ border-radius: 20px;
52
+ transition: all 0.3s ease;
53
+ font-weight: 500;
54
+ }
55
+
56
+ .nav-link:hover, .nav-link.active {
57
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
58
+ color: white;
59
+ }
60
+
61
+ .container {
62
+ flex: 1;
63
+ display: flex;
64
+ justify-content: center;
65
+ align-items: center;
66
+ padding: 20px;
67
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
68
+ }
69
+
70
+ .content {
71
+ background: rgba(255, 255, 255, 0.95);
72
+ backdrop-filter: blur(10px);
73
+ border-radius: 20px;
74
+ box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
75
+ padding: 40px;
76
+ width: 100%;
77
+ max-width: 600px;
78
+ text-align: center;
79
+ }
80
+
81
+ h1 {
82
+ color: #333;
83
+ margin-bottom: 10px;
84
+ font-size: 2.5em;
85
+ text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
86
+ }
87
+
88
+ .subtitle {
89
+ color: #666;
90
+ margin-bottom: 30px;
91
+ font-size: 1.1em;
92
+ }
93
+
94
+ .upload-area {
95
+ border: 3px dashed #667eea;
96
+ border-radius: 15px;
97
+ padding: 40px 20px;
98
+ margin: 20px 0;
99
+ cursor: pointer;
100
+ transition: all 0.3s ease;
101
+ background: rgba(102, 126, 234, 0.05);
102
+ }
103
+
104
+ .upload-area:hover, .upload-area.dragover {
105
+ background: rgba(102, 126, 234, 0.1);
106
+ border-color: #764ba2;
107
+ }
108
+
109
+ .upload-icon {
110
+ font-size: 4em;
111
+ color: #667eea;
112
+ margin-bottom: 15px;
113
+ }
114
+
115
+ .upload-text {
116
+ color: #666;
117
+ margin-bottom: 15px;
118
+ }
119
+
120
+ .file-input {
121
+ display: none;
122
+ }
123
+
124
+ .btn {
125
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
126
+ color: white;
127
+ border: none;
128
+ padding: 12px 30px;
129
+ border-radius: 25px;
130
+ cursor: pointer;
131
+ font-size: 16px;
132
+ font-weight: 600;
133
+ transition: all 0.3s ease;
134
+ margin: 10px 5px;
135
+ box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
136
+ }
137
+
138
+ .btn:hover {
139
+ transform: translateY(-2px);
140
+ box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
141
+ }
142
+
143
+ .btn:disabled {
144
+ opacity: 0.6;
145
+ cursor: not-allowed;
146
+ transform: none;
147
+ }
148
+
149
+ .btn-secondary {
150
+ background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
151
+ }
152
+
153
+ .progress-container {
154
+ margin: 20px 0;
155
+ display: none;
156
+ }
157
+
158
+ .progress-bar {
159
+ width: 100%;
160
+ height: 20px;
161
+ background-color: #e0e0e0;
162
+ border-radius: 10px;
163
+ overflow: hidden;
164
+ position: relative;
165
+ }
166
+
167
+ .progress-fill {
168
+ height: 100%;
169
+ background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
170
+ width: 0%;
171
+ transition: width 0.3s ease;
172
+ }
173
+
174
+ .progress-text {
175
+ margin-top: 10px;
176
+ font-weight: 600;
177
+ color: #333;
178
+ }
179
+
180
+ .result-container {
181
+ margin: 20px 0;
182
+ display: none;
183
+ }
184
+
185
+ .result-message {
186
+ padding: 15px;
187
+ border-radius: 10px;
188
+ margin-bottom: 15px;
189
+ text-align: left;
190
+ }
191
+
192
+ .success {
193
+ background-color: #d4edda;
194
+ color: #155724;
195
+ border: 1px solid #c3e6cb;
196
+ }
197
+
198
+ .error {
199
+ background-color: #f8d7da;
200
+ color: #721c24;
201
+ border: 1px solid #f5c6cb;
202
+ }
203
+
204
+ .floating-element {
205
+ position: absolute;
206
+ width: 100px;
207
+ height: 100px;
208
+ background: rgba(255, 255, 255, 0.1);
209
+ border-radius: 50%;
210
+ animation: float 6s ease-in-out infinite;
211
+ z-index: -1;
212
+ }
213
+
214
+ .floating-element:nth-child(1) {
215
+ top: 10%;
216
+ left: 10%;
217
+ animation-delay: 0s;
218
+ }
219
+
220
+ .floating-element:nth-child(2) {
221
+ top: 20%;
222
+ right: 10%;
223
+ animation-delay: 2s;
224
+ width: 80px;
225
+ height: 80px;
226
+ }
227
+
228
+ .floating-element:nth-child(3) {
229
+ bottom: 10%;
230
+ left: 20%;
231
+ animation-delay: 4s;
232
+ width: 60px;
233
+ height: 60px;
234
+ }
235
+
236
+ @keyframes float {
237
+ 0%, 100% { transform: translateY(0px) rotate(0deg); }
238
+ 50% { transform: translateY(-20px) rotate(180deg); }
239
+ }
240
+
241
+ @media (max-width: 768px) {
242
+ .content {
243
+ padding: 20px;
244
+ margin: 10px;
245
+ }
246
+
247
+ h1 {
248
+ font-size: 2em;
249
+ }
250
+ }
251
+ </style>
252
+ </head>
253
+ <body>
254
+ <!-- Floating elements for visual effect -->
255
+ <div class="floating-element"></div>
256
+ <div class="floating-element"></div>
257
+ <div class="floating-element"></div>
258
+
259
+ <nav class="navbar">
260
+ <a href="/" class="logo">DocConverter Pro</a>
261
+ <div class="nav-links">
262
+ <a href="/" class="nav-link">Home</a>
263
+ <a href="/pdf-ocr" class="nav-link active">PDF OCR</a>
264
+ <a href="/excel-to-csv" class="nav-link">Excel to CSV</a>
265
+ </div>
266
+ </nav>
267
+
268
+ <div class="container">
269
+ <div class="content">
270
+ <h1>PDF OCR Converter</h1>
271
+ <p class="subtitle">Convert scanned PDFs to searchable, text-based PDFs</p>
272
+
273
+ <div class="upload-area" id="uploadArea">
274
+ <div class="upload-icon">📄</div>
275
+ <p class="upload-text">Drag & drop your PDF here or click to browse</p>
276
+ <p class="upload-subtext">Supports: PDF files only</p>
277
+ <input type="file" id="fileInput" class="file-input" accept=".pdf">
278
+ </div>
279
+
280
+ <button id="uploadBtn" class="btn">Upload PDF</button>
281
+
282
+ <div class="progress-container" id="progressContainer">
283
+ <div class="progress-bar">
284
+ <div class="progress-fill" id="progressFill"></div>
285
+ </div>
286
+ <div class="progress-text" id="progressText">Processing... 0%</div>
287
+ </div>
288
+
289
+ <div class="result-container" id="resultContainer">
290
+ <div id="resultMessage" class="result-message"></div>
291
+ <button id="downloadBtn" class="btn" style="display:none;">Download OCRed PDF</button>
292
+ <button id="newConversionBtn" class="btn btn-secondary">New Conversion</button>
293
+ </div>
294
+ </div>
295
+ </div>
296
+
297
+ <script>
298
+ document.addEventListener('DOMContentLoaded', function() {
299
+ const fileInput = document.getElementById('fileInput');
300
+ const uploadArea = document.getElementById('uploadArea');
301
+ const uploadBtn = document.getElementById('uploadBtn');
302
+ const progressContainer = document.getElementById('progressContainer');
303
+ const progressFill = document.getElementById('progressFill');
304
+ const progressText = document.getElementById('progressText');
305
+ const resultContainer = document.getElementById('resultContainer');
306
+ const resultMessage = document.getElementById('resultMessage');
307
+ const downloadBtn = document.getElementById('downloadBtn');
308
+ const newConversionBtn = document.getElementById('newConversionBtn');
309
+
310
+ let currentJobId = null;
311
+
312
+ // Click on upload area triggers file input
313
+ uploadArea.addEventListener('click', () => {
314
+ fileInput.click();
315
+ });
316
+
317
+ // Drag and drop functionality
318
+ uploadArea.addEventListener('dragover', (e) => {
319
+ e.preventDefault();
320
+ uploadArea.classList.add('dragover');
321
+ });
322
+
323
+ uploadArea.addEventListener('dragleave', () => {
324
+ uploadArea.classList.remove('dragover');
325
+ });
326
+
327
+ uploadArea.addEventListener('drop', (e) => {
328
+ e.preventDefault();
329
+ uploadArea.classList.remove('dragover');
330
+
331
+ if (e.dataTransfer.files.length) {
332
+ fileInput.files = e.dataTransfer.files;
333
+ updateFileNameDisplay();
334
+ }
335
+ });
336
+
337
+ // Handle file selection
338
+ fileInput.addEventListener('change', updateFileNameDisplay);
339
+
340
+ function updateFileNameDisplay() {
341
+ if (fileInput.files.length > 0) {
342
+ const fileName = fileInput.files[0].name;
343
+ uploadArea.querySelector('.upload-text').textContent = `Selected: ${fileName}`;
344
+ }
345
+ }
346
+
347
+ // Upload button click handler
348
+ uploadBtn.addEventListener('click', () => {
349
+ if (!fileInput.files.length) {
350
+ alert('Please select a PDF file first.');
351
+ return;
352
+ }
353
+
354
+ const file = fileInput.files[0];
355
+ if (!file.name.toLowerCase().endsWith('.pdf')) {
356
+ alert('Please select a PDF file.');
357
+ return;
358
+ }
359
+
360
+ uploadFile(file);
361
+ });
362
+
363
+ // Upload file function
364
+ async function uploadFile(file) {
365
+ const formData = new FormData();
366
+ formData.append('pdf_file', file);
367
+
368
+ try {
369
+ uploadBtn.disabled = true;
370
+ progressContainer.style.display = 'block';
371
+ resultContainer.style.display = 'none';
372
+
373
+ const response = await fetch('/upload', {
374
+ method: 'POST',
375
+ body: formData
376
+ });
377
+
378
+ const result = await response.json();
379
+
380
+ if (result.success) {
381
+ currentJobId = result.job_id;
382
+ resultMessage.textContent = result.message;
383
+ resultMessage.className = 'result-message success';
384
+ resultContainer.style.display = 'block';
385
+
386
+ // Poll for processing status
387
+ pollForStatus(currentJobId);
388
+ } else {
389
+ resultMessage.textContent = result.message || 'Upload failed';
390
+ resultMessage.className = 'result-message error';
391
+ resultContainer.style.display = 'block';
392
+ progressContainer.style.display = 'none';
393
+ uploadBtn.disabled = false;
394
+ }
395
+ } catch (error) {
396
+ console.error('Upload error:', error);
397
+ resultMessage.textContent = 'Upload failed: ' + error.message;
398
+ resultMessage.className = 'result-message error';
399
+ resultContainer.style.display = 'block';
400
+ progressContainer.style.display = 'none';
401
+ uploadBtn.disabled = false;
402
+ }
403
+ }
404
+
405
+ // Poll for processing status
406
+ async function pollForStatus(jobId) {
407
+ const statusUrl = `/status/${jobId}`;
408
+
409
+ const interval = setInterval(async () => {
410
+ try {
411
+ const response = await fetch(statusUrl);
412
+ const status = await response.json();
413
+
414
+ if (status.status === 'processing') {
415
+ // Update progress
416
+ const progress = status.progress || 0;
417
+ progressFill.style.width = `${progress}%`;
418
+ progressText.textContent = `Processing... ${progress}%`;
419
+ } else if (status.status === 'completed') {
420
+ // Processing completed
421
+ clearInterval(interval);
422
+ progressFill.style.width = '100%';
423
+ progressText.textContent = 'Processing Completed!';
424
+
425
+ // Enable download button
426
+ downloadBtn.onclick = () => {
427
+ window.location.href = `/download/${jobId}`;
428
+ };
429
+ downloadBtn.style.display = 'inline-block';
430
+ } else if (status.status === 'failed') {
431
+ // Processing failed
432
+ clearInterval(interval);
433
+ resultMessage.textContent = `Processing failed: ${status.error || 'Unknown error'}`;
434
+ resultMessage.className = 'result-message error';
435
+ progressContainer.style.display = 'none';
436
+ uploadBtn.disabled = false;
437
+ } else if (status.status === 'not_found') {
438
+ // Job not found
439
+ clearInterval(interval);
440
+ resultMessage.textContent = 'Job not found';
441
+ resultMessage.className = 'result-message error';
442
+ progressContainer.style.display = 'none';
443
+ uploadBtn.disabled = false;
444
+ }
445
+ } catch (error) {
446
+ console.error('Status check error:', error);
447
+ clearInterval(interval);
448
+ resultMessage.textContent = 'Error checking status: ' + error.message;
449
+ resultMessage.className = 'result-message error';
450
+ progressContainer.style.display = 'none';
451
+ uploadBtn.disabled = false;
452
+ }
453
+ }, 2000); // Check every 2 seconds
454
+ }
455
+
456
+ // New conversion button
457
+ newConversionBtn.addEventListener('click', () => {
458
+ // Reset form
459
+ fileInput.value = '';
460
+ uploadArea.querySelector('.upload-text').textContent = 'Drag & drop your PDF here or click to browse';
461
+ progressContainer.style.display = 'none';
462
+ resultContainer.style.display = 'none';
463
+ uploadBtn.disabled = false;
464
+ currentJobId = null;
465
+ });
466
+ });
467
+ </script>
468
+ </body>
469
+ </html>
OCR Extracter web app - for pdf/uploads/6bf37a2b-75cf-4698-afaf-d6edeeecdb55_sample_report.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8650d19c45cc72390eb0968f166664357101fab1d1810f3083ccbd797451a827
3
+ size 248952
OCR Extracter web app - for pdf/uploads/e9869372-a4ab-4e20-82b6-09ce6180bb97_Aug.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:304bbf47165ec9357d04e44657a9a7518c62e3568a7bdaf34ccd5e8265fd43e9
3
+ size 122013