File size: 27,746 Bytes
1f85a2f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>PDF Magic Converter | Read, OCR & Convert Files</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .dropzone {
            border: 2px dashed #3b82f6;
            transition: all 0.3s ease;
        }
        .dropzone.active {
            border-color: #10b981;
            background-color: #f0f9ff;
        }
        .progress-bar {
            transition: width 0.3s ease;
        }
        .pdf-viewer {
            height: 70vh;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        }
        .format-option:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        }
        .sidebar {
            transition: all 0.3s ease;
        }
        @media (max-width: 768px) {
            .sidebar {
                transform: translateX(-100%);
            }
            .sidebar.open {
                transform: translateX(0);
            }
        }
    </style>
</head>
<body class="bg-gray-50 font-sans">
    <!-- Mobile Menu Button -->
    <button id="menuToggle" class="md:hidden fixed top-4 left-4 z-50 bg-blue-500 text-white p-2 rounded-lg shadow-lg">
        <i class="fas fa-bars"></i>
    </button>

    <!-- Sidebar -->
    <div id="sidebar" class="sidebar fixed top-0 left-0 h-full w-64 bg-white shadow-lg z-40 p-4 overflow-y-auto">
        <div class="flex items-center mb-8">
            <i class="fas fa-file-pdf text-red-500 text-2xl mr-2"></i>
            <h1 class="text-xl font-bold text-gray-800">PDF Magic</h1>
        </div>
        
        <div class="mb-6">
            <h2 class="text-sm uppercase font-semibold text-gray-500 mb-2">Navigation</h2>
            <ul>
                <li class="mb-1">
                    <a href="#" class="flex items-center p-2 text-blue-600 rounded-lg bg-blue-50">
                        <i class="fas fa-home mr-3"></i>
                        <span>Dashboard</span>
                    </a>
                </li>
                <li class="mb-1">
                    <a href="#" class="flex items-center p-2 text-gray-600 hover:bg-gray-100 rounded-lg">
                        <i class="fas fa-history mr-3"></i>
                        <span>Recent Files</span>
                    </a>
                </li>
                <li class="mb-1">
                    <a href="#" class="flex items-center p-2 text-gray-600 hover:bg-gray-100 rounded-lg">
                        <i class="fas fa-cog mr-3"></i>
                        <span>Settings</span>
                    </a>
                </li>
            </ul>
        </div>
        
        <div>
            <h2 class="text-sm uppercase font-semibold text-gray-500 mb-2">Tools</h2>
            <ul>
                <li class="mb-1">
                    <a href="#" class="flex items-center p-2 text-gray-600 hover:bg-gray-100 rounded-lg">
                        <i class="fas fa-file-export mr-3"></i>
                        <span>Batch Convert</span>
                    </a>
                </li>
                <li class="mb-1">
                    <a href="#" class="flex items-center p-2 text-gray-600 hover:bg-gray-100 rounded-lg">
                        <i class="fas fa-key mr-3"></i>
                        <span>Secure PDF</span>
                    </a>
                </li>
                <li class="mb-1">
                    <a href="#" class="flex items-center p-2 text-gray-600 hover:bg-gray-100 rounded-lg">
                        <i class="fas fa-font mr-3"></i>
                        <span>OCR Settings</span>
                    </a>
                </li>
            </ul>
        </div>
        
        <div class="mt-8 pt-4 border-t border-gray-200">
            <div class="flex items-center">
                <div class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center text-blue-600">
                    <i class="fas fa-user"></i>
                </div>
                <div class="ml-3">
                    <p class="text-sm font-medium text-gray-700">John Doe</p>
                    <p class="text-xs text-gray-500">Free Plan</p>
                </div>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="ml-0 md:ml-64 p-4 md:p-8">
        <div class="max-w-6xl mx-auto">
            <header class="mb-8">
                <h1 class="text-3xl font-bold text-gray-800 mb-2">PDF Converter with OCR</h1>
                <p class="text-gray-600">Upload your PDF files, extract text with OCR if needed, and convert to any format</p>
            </header>
            
            <!-- Upload Section -->
            <div class="bg-white rounded-xl shadow-md p-6 mb-8">
                <div id="dropzone" class="dropzone rounded-lg p-8 text-center cursor-pointer">
                    <div class="flex flex-col items-center justify-center">
                        <i class="fas fa-file-upload text-4xl text-blue-500 mb-4"></i>
                        <h3 class="text-xl font-semibold text-gray-700 mb-2">Drag & Drop your PDF file here</h3>
                        <p class="text-gray-500 mb-4">or click to browse files</p>
                        <input type="file" id="fileInput" class="hidden" accept=".pdf">
                        <button id="browseBtn" class="bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-6 rounded-lg transition duration-200">
                            Select File
                        </button>
                    </div>
                </div>
                
                <div id="fileInfo" class="hidden mt-4 p-4 bg-blue-50 rounded-lg">
                    <div class="flex items-center">
                        <i class="fas fa-file-pdf text-red-500 text-2xl mr-3"></i>
                        <div class="flex-1">
                            <div class="flex justify-between items-center">
                                <span id="fileName" class="font-medium text-gray-800">sample.pdf</span>
                                <span id="fileSize" class="text-sm text-gray-500">2.4 MB</span>
                            </div>
                            <div class="w-full bg-gray-200 rounded-full h-2.5 mt-2">
                                <div id="uploadProgress" class="progress-bar bg-blue-600 h-2.5 rounded-full" style="width: 0%"></div>
                            </div>
                        </div>
                        <button id="cancelUpload" class="ml-4 text-gray-500 hover:text-gray-700">
                            <i class="fas fa-times"></i>
                        </button>
                    </div>
                </div>
            </div>
            
            <!-- Processing Options -->
            <div id="processingOptions" class="hidden bg-white rounded-xl shadow-md p-6 mb-8">
                <h2 class="text-xl font-semibold text-gray-800 mb-4">Processing Options</h2>
                
                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                    <!-- OCR Options -->
                    <div class="bg-gray-50 p-4 rounded-lg">
                        <div class="flex items-center mb-3">
                            <i class="fas fa-font text-blue-500 mr-2"></i>
                            <h3 class="font-medium text-gray-700">OCR Settings</h3>
                        </div>
                        <div class="space-y-3">
                            <div class="flex items-center">
                                <input id="autoOcr" type="checkbox" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded" checked>
                                <label for="autoOcr" class="ml-2 block text-sm text-gray-700">Auto-detect and apply OCR if needed</label>
                            </div>
                            <div class="ml-6 space-y-2">
                                <div class="flex items-center">
                                    <input id="ocrEnglish" type="radio" name="ocrLanguage" value="eng" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300" checked>
                                    <label for="ocrEnglish" class="ml-2 block text-sm text-gray-700">English</label>
                                </div>
                                <div class="flex items-center">
                                    <input id="ocrSpanish" type="radio" name="ocrLanguage" value="spa" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300">
                                    <label for="ocrSpanish" class="ml-2 block text-sm text-gray-700">Spanish</label>
                                </div>
                                <div class="flex items-center">
                                    <input id="ocrFrench" type="radio" name="ocrLanguage" value="fra" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300">
                                    <label for="ocrFrench" class="ml-2 block text-sm text-gray-700">French</label>
                                </div>
                            </div>
                            <div class="flex items-center mt-2">
                                <input id="enhanceOcr" type="checkbox" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded" checked>
                                <label for="enhanceOcr" class="ml-2 block text-sm text-gray-700">Enhance image quality before OCR</label>
                            </div>
                        </div>
                    </div>
                    
                    <!-- Conversion Options -->
                    <div class="bg-gray-50 p-4 rounded-lg">
                        <div class="flex items-center mb-3">
                            <i class="fas fa-exchange-alt text-blue-500 mr-2"></i>
                            <h3 class="font-medium text-gray-700">Conversion Options</h3>
                        </div>
                        <div class="space-y-3">
                            <label class="block text-sm font-medium text-gray-700">Output Format</label>
                            <div class="grid grid-cols-3 gap-2">
                                <button data-format="docx" class="format-option bg-white border border-gray-200 rounded-lg p-3 text-center hover:border-blue-300 transition">
                                    <i class="fas fa-file-word text-blue-500 text-2xl mb-1"></i>
                                    <span class="block text-xs font-medium">DOCX</span>
                                </button>
                                <button data-format="txt" class="format-option bg-white border border-gray-200 rounded-lg p-3 text-center hover:border-blue-300 transition">
                                    <i class="fas fa-file-alt text-gray-500 text-2xl mb-1"></i>
                                    <span class="block text-xs font-medium">TXT</span>
                                </button>
                                <button data-format="html" class="format-option bg-white border border-gray-200 rounded-lg p-3 text-center hover:border-blue-300 transition">
                                    <i class="fas fa-code text-orange-500 text-2xl mb-1"></i>
                                    <span class="block text-xs font-medium">HTML</span>
                                </button>
                                <button data-format="epub" class="format-option bg-white border border-gray-200 rounded-lg p-3 text-center hover:border-blue-300 transition">
                                    <i class="fas fa-book text-purple-500 text-2xl mb-1"></i>
                                    <span class="block text-xs font-medium">EPUB</span>
                                </button>
                                <button data-format="odt" class="format-option bg-white border border-gray-200 rounded-lg p-3 text-center hover:border-blue-300 transition">
                                    <i class="fas fa-file-alt text-blue-400 text-2xl mb-1"></i>
                                    <span class="block text-xs font-medium">ODT</span>
                                </button>
                                <button data-format="markdown" class="format-option bg-white border border-gray-200 rounded-lg p-3 text-center hover:border-blue-300 transition">
                                    <i class="fas fa-file-code text-gray-700 text-2xl mb-1"></i>
                                    <span class="block text-xs font-medium">Markdown</span>
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="mt-6 flex justify-end">
                    <button id="processBtn" class="bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-6 rounded-lg transition duration-200 flex items-center">
                        <i class="fas fa-cog mr-2"></i> Process File
                    </button>
                </div>
            </div>
            
            <!-- Results Section -->
            <div id="resultsSection" class="hidden bg-white rounded-xl shadow-md p-6">
                <div class="flex justify-between items-center mb-4">
                    <h2 class="text-xl font-semibold text-gray-800">Results</h2>
                    <div class="flex space-x-2">
                        <button id="downloadBtn" class="bg-green-500 hover:bg-green-600 text-white font-medium py-2 px-4 rounded-lg transition duration-200 flex items-center">
                            <i class="fas fa-download mr-2"></i> Download
                        </button>
                        <button id="newFileBtn" class="bg-gray-200 hover:bg-gray-300 text-gray-700 font-medium py-2 px-4 rounded-lg transition duration-200 flex items-center">
                            <i class="fas fa-plus mr-2"></i> New File
                        </button>
                    </div>
                </div>
                
                <div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
                    <!-- Original PDF Viewer -->
                    <div class="lg:col-span-1">
                        <div class="bg-gray-100 rounded-lg p-3 mb-2">
                            <h3 class="font-medium text-gray-700 flex items-center">
                                <i class="fas fa-file-pdf text-red-500 mr-2"></i> Original PDF
                            </h3>
                        </div>
                        <div class="pdf-viewer bg-gray-50 rounded-lg overflow-hidden">
                            <div class="h-full flex items-center justify-center text-gray-400">
                                <div class="text-center">
                                    <i class="fas fa-file-pdf text-5xl mb-2"></i>
                                    <p>PDF Preview</p>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <!-- Extracted Text -->
                    <div class="lg:col-span-2">
                        <div class="bg-gray-100 rounded-lg p-3 mb-2">
                            <h3 class="font-medium text-gray-700 flex items-center">
                                <i class="fas fa-font text-blue-500 mr-2"></i> Extracted Text
                            </h3>
                        </div>
                        <div class="pdf-viewer bg-white border border-gray-200 rounded-lg p-4 overflow-y-auto">
                            <div id="extractedText" class="prose max-w-none">
                                <p class="text-gray-500 italic">Text will appear here after processing...</p>
                            </div>
                        </div>
                    </div>
                </div>
                
                <!-- Conversion Status -->
                <div id="conversionStatus" class="mt-6 hidden">
                    <div class="bg-blue-50 border-l-4 border-blue-500 p-4">
                        <div class="flex">
                            <div class="flex-shrink-0">
                                <i class="fas fa-cog fa-spin text-blue-500"></i>
                            </div>
                            <div class="ml-3">
                                <h3 class="text-sm font-medium text-blue-800">Processing your file</h3>
                                <div class="mt-2 text-sm text-blue-700">
                                    <p id="statusMessage">Performing OCR and converting to DOCX...</p>
                                    <div class="w-full bg-gray-200 rounded-full h-2.5 mt-2">
                                        <div id="processProgress" class="progress-bar bg-blue-600 h-2.5 rounded-full" style="width: 0%"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- Features Section -->
            <div class="mt-12">
                <h2 class="text-2xl font-bold text-gray-800 mb-6 text-center">Why Choose PDF Magic?</h2>
                <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                    <div class="bg-white p-6 rounded-xl shadow-sm hover:shadow-md transition">
                        <div class="text-blue-500 mb-4">
                            <i class="fas fa-robot text-3xl"></i>
                        </div>
                        <h3 class="text-lg font-semibold mb-2">Smart OCR</h3>
                        <p class="text-gray-600">Automatically detects scanned documents and applies high-quality OCR to extract text with precision.</p>
                    </div>
                    <div class="bg-white p-6 rounded-xl shadow-sm hover:shadow-md transition">
                        <div class="text-green-500 mb-4">
                            <i class="fas fa-exchange-alt text-3xl"></i>
                        </div>
                        <h3 class="text-lg font-semibold mb-2">Multi-format Conversion</h3>
                        <p class="text-gray-600">Convert your PDFs to DOCX, TXT, HTML, EPUB and more using powerful Pandoc engine.</p>
                    </div>
                    <div class="bg-white p-6 rounded-xl shadow-sm hover:shadow-md transition">
                        <div class="text-purple-500 mb-4">
                            <i class="fas fa-lock text-3xl"></i>
                        </div>
                        <h3 class="text-lg font-semibold mb-2">Secure Processing</h3>
                        <p class="text-gray-600">Your files are processed securely in your browser and never uploaded to our servers.</p>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        // Mobile menu toggle
        document.getElementById('menuToggle').addEventListener('click', function() {
            document.getElementById('sidebar').classList.toggle('open');
        });

        // File upload handling
        const dropzone = document.getElementById('dropzone');
        const fileInput = document.getElementById('fileInput');
        const browseBtn = document.getElementById('browseBtn');
        const fileInfo = document.getElementById('fileInfo');
        const fileName = document.getElementById('fileName');
        const fileSize = document.getElementById('fileSize');
        const uploadProgress = document.getElementById('uploadProgress');
        const cancelUpload = document.getElementById('cancelUpload');
        const processingOptions = document.getElementById('processingOptions');
        const resultsSection = document.getElementById('resultsSection');
        const processBtn = document.getElementById('processBtn');
        const downloadBtn = document.getElementById('downloadBtn');
        const newFileBtn = document.getElementById('newFileBtn');
        const conversionStatus = document.getElementById('conversionStatus');
        const statusMessage = document.getElementById('statusMessage');
        const processProgress = document.getElementById('processProgress');
        const extractedText = document.getElementById('extractedText');
        const formatOptions = document.querySelectorAll('.format-option');
        
        let selectedFormat = 'docx';
        let currentFile = null;

        // Highlight dropzone when dragging over
        ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
            dropzone.addEventListener(eventName, preventDefaults, false);
        });

        function preventDefaults(e) {
            e.preventDefault();
            e.stopPropagation();
        }

        ['dragenter', 'dragover'].forEach(eventName => {
            dropzone.addEventListener(eventName, highlight, false);
        });

        ['dragleave', 'drop'].forEach(eventName => {
            dropzone.addEventListener(eventName, unhighlight, false);
        });

        function highlight() {
            dropzone.classList.add('active');
        }

        function unhighlight() {
            dropzone.classList.remove('active');
        }

        // Handle dropped files
        dropzone.addEventListener('drop', handleDrop, false);

        function handleDrop(e) {
            const dt = e.dataTransfer;
            const files = dt.files;
            handleFiles(files);
        }

        // Handle file selection via button
        browseBtn.addEventListener('click', () => {
            fileInput.click();
        });

        fileInput.addEventListener('change', () => {
            if (fileInput.files.length) {
                handleFiles(fileInput.files);
            }
        });

        // Cancel upload
        cancelUpload.addEventListener('click', () => {
            resetUpload();
        });

        // New file button
        newFileBtn.addEventListener('click', resetUpload);

        // Format selection
        formatOptions.forEach(option => {
            option.addEventListener('click', function() {
                formatOptions.forEach(opt => opt.classList.remove('border-blue-500', 'bg-blue-50'));
                this.classList.add('border-blue-500', 'bg-blue-50');
                selectedFormat = this.dataset.format;
            });
        });

        // Process file button
        processBtn.addEventListener('click', processFile);

        // Download button
        downloadBtn.addEventListener('click', () => {
            alert(`Downloading file in ${selectedFormat.toUpperCase()} format`);
            // In a real app, this would trigger the download of the converted file
        });

        function handleFiles(files) {
            currentFile = files[0];
            
            // Update file info
            fileName.textContent = currentFile.name;
            fileSize.textContent = formatFileSize(currentFile.size);
            
            // Show file info and hide dropzone
            fileInfo.classList.remove('hidden');
            dropzone.classList.add('hidden');
            
            // Simulate upload progress
            let progress = 0;
            const interval = setInterval(() => {
                progress += Math.random() * 10;
                if (progress >= 100) {
                    progress = 100;
                    clearInterval(interval);
                    uploadComplete();
                }
                uploadProgress.style.width = `${progress}%`;
            }, 200);
        }

        function uploadComplete() {
            processingOptions.classList.remove('hidden');
        }

        function processFile() {
            processingOptions.classList.add('hidden');
            conversionStatus.classList.remove('hidden');
            resultsSection.classList.remove('hidden');
            
            // Simulate processing steps
            let progress = 0;
            const steps = [
                {progress: 20, message: "Analyzing PDF content..."},
                {progress: 40, message: "Detecting text layers..."},
                {progress: 60, message: "Applying OCR to scanned pages..."},
                {progress: 80, message: `Converting to ${selectedFormat.toUpperCase()} format...`},
                {progress: 100, message: "Conversion complete!"}
            ];
            
            let currentStep = 0;
            const processInterval = setInterval(() => {
                if (currentStep < steps.length) {
                    progress = steps[currentStep].progress;
                    statusMessage.textContent = steps[currentStep].message;
                    processProgress.style.width = `${progress}%`;
                    currentStep++;
                    
                    // Update extracted text at certain steps
                    if (currentStep === 3) {
                        extractedText.innerHTML = `
                            <h1>Sample Extracted Document</h1>
                            <p>This is text that was extracted from your PDF document using our advanced OCR technology.</p>
                            <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam in dui mauris. Vivamus hendrerit arcu sed erat molestie vehicula.</p>
                            <h2>Section 1</h2>
                            <p>Sed auctor neque eu tellus rhoncus ut eleifend nibh porttitor. Ut in nulla enim. Phasellus molestie magna non est bibendum non venenatis nisl tempor.</p>
                            <p>This text would normally be extracted from your actual PDF file.</p>
                        `;
                    }
                } else {
                    clearInterval(processInterval);
                    conversionStatus.classList.add('hidden');
                }
            }, 1500);
        }

        function resetUpload() {
            fileInfo.classList.add('hidden');
            processingOptions.classList.add('hidden');
            resultsSection.classList.add('hidden');
            conversionStatus.classList.add('hidden');
            dropzone.classList.remove('hidden');
            uploadProgress.style.width = '0%';
            processProgress.style.width = '0%';
            fileInput.value = '';
            currentFile = null;
            extractedText.innerHTML = '<p class="text-gray-500 italic">Text will appear here after processing...</p>';
        }

        function formatFileSize(bytes) {
            if (bytes === 0) return '0 Bytes';
            const k = 1024;
            const sizes = ['Bytes', 'KB', 'MB', 'GB'];
            const i = Math.floor(Math.log(bytes) / Math.log(k));
            return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
        }
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=RedSparkie/epub" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>