RedSparkie commited on
Commit
1f85a2f
·
verified ·
1 Parent(s): 0683e3c

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +529 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Epub
3
- emoji: 🚀
4
- colorFrom: yellow
5
- colorTo: purple
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: epub
3
+ emoji: 🐳
4
+ colorFrom: green
5
+ colorTo: green
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,529 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Magic Converter | Read, OCR & Convert Files</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ .dropzone {
11
+ border: 2px dashed #3b82f6;
12
+ transition: all 0.3s ease;
13
+ }
14
+ .dropzone.active {
15
+ border-color: #10b981;
16
+ background-color: #f0f9ff;
17
+ }
18
+ .progress-bar {
19
+ transition: width 0.3s ease;
20
+ }
21
+ .pdf-viewer {
22
+ height: 70vh;
23
+ box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
24
+ }
25
+ .format-option:hover {
26
+ transform: translateY(-2px);
27
+ box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
28
+ }
29
+ .sidebar {
30
+ transition: all 0.3s ease;
31
+ }
32
+ @media (max-width: 768px) {
33
+ .sidebar {
34
+ transform: translateX(-100%);
35
+ }
36
+ .sidebar.open {
37
+ transform: translateX(0);
38
+ }
39
+ }
40
+ </style>
41
+ </head>
42
+ <body class="bg-gray-50 font-sans">
43
+ <!-- Mobile Menu Button -->
44
+ <button id="menuToggle" class="md:hidden fixed top-4 left-4 z-50 bg-blue-500 text-white p-2 rounded-lg shadow-lg">
45
+ <i class="fas fa-bars"></i>
46
+ </button>
47
+
48
+ <!-- Sidebar -->
49
+ <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">
50
+ <div class="flex items-center mb-8">
51
+ <i class="fas fa-file-pdf text-red-500 text-2xl mr-2"></i>
52
+ <h1 class="text-xl font-bold text-gray-800">PDF Magic</h1>
53
+ </div>
54
+
55
+ <div class="mb-6">
56
+ <h2 class="text-sm uppercase font-semibold text-gray-500 mb-2">Navigation</h2>
57
+ <ul>
58
+ <li class="mb-1">
59
+ <a href="#" class="flex items-center p-2 text-blue-600 rounded-lg bg-blue-50">
60
+ <i class="fas fa-home mr-3"></i>
61
+ <span>Dashboard</span>
62
+ </a>
63
+ </li>
64
+ <li class="mb-1">
65
+ <a href="#" class="flex items-center p-2 text-gray-600 hover:bg-gray-100 rounded-lg">
66
+ <i class="fas fa-history mr-3"></i>
67
+ <span>Recent Files</span>
68
+ </a>
69
+ </li>
70
+ <li class="mb-1">
71
+ <a href="#" class="flex items-center p-2 text-gray-600 hover:bg-gray-100 rounded-lg">
72
+ <i class="fas fa-cog mr-3"></i>
73
+ <span>Settings</span>
74
+ </a>
75
+ </li>
76
+ </ul>
77
+ </div>
78
+
79
+ <div>
80
+ <h2 class="text-sm uppercase font-semibold text-gray-500 mb-2">Tools</h2>
81
+ <ul>
82
+ <li class="mb-1">
83
+ <a href="#" class="flex items-center p-2 text-gray-600 hover:bg-gray-100 rounded-lg">
84
+ <i class="fas fa-file-export mr-3"></i>
85
+ <span>Batch Convert</span>
86
+ </a>
87
+ </li>
88
+ <li class="mb-1">
89
+ <a href="#" class="flex items-center p-2 text-gray-600 hover:bg-gray-100 rounded-lg">
90
+ <i class="fas fa-key mr-3"></i>
91
+ <span>Secure PDF</span>
92
+ </a>
93
+ </li>
94
+ <li class="mb-1">
95
+ <a href="#" class="flex items-center p-2 text-gray-600 hover:bg-gray-100 rounded-lg">
96
+ <i class="fas fa-font mr-3"></i>
97
+ <span>OCR Settings</span>
98
+ </a>
99
+ </li>
100
+ </ul>
101
+ </div>
102
+
103
+ <div class="mt-8 pt-4 border-t border-gray-200">
104
+ <div class="flex items-center">
105
+ <div class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center text-blue-600">
106
+ <i class="fas fa-user"></i>
107
+ </div>
108
+ <div class="ml-3">
109
+ <p class="text-sm font-medium text-gray-700">John Doe</p>
110
+ <p class="text-xs text-gray-500">Free Plan</p>
111
+ </div>
112
+ </div>
113
+ </div>
114
+ </div>
115
+
116
+ <!-- Main Content -->
117
+ <div class="ml-0 md:ml-64 p-4 md:p-8">
118
+ <div class="max-w-6xl mx-auto">
119
+ <header class="mb-8">
120
+ <h1 class="text-3xl font-bold text-gray-800 mb-2">PDF Converter with OCR</h1>
121
+ <p class="text-gray-600">Upload your PDF files, extract text with OCR if needed, and convert to any format</p>
122
+ </header>
123
+
124
+ <!-- Upload Section -->
125
+ <div class="bg-white rounded-xl shadow-md p-6 mb-8">
126
+ <div id="dropzone" class="dropzone rounded-lg p-8 text-center cursor-pointer">
127
+ <div class="flex flex-col items-center justify-center">
128
+ <i class="fas fa-file-upload text-4xl text-blue-500 mb-4"></i>
129
+ <h3 class="text-xl font-semibold text-gray-700 mb-2">Drag & Drop your PDF file here</h3>
130
+ <p class="text-gray-500 mb-4">or click to browse files</p>
131
+ <input type="file" id="fileInput" class="hidden" accept=".pdf">
132
+ <button id="browseBtn" class="bg-blue-500 hover:bg-blue-600 text-white font-medium py-2 px-6 rounded-lg transition duration-200">
133
+ Select File
134
+ </button>
135
+ </div>
136
+ </div>
137
+
138
+ <div id="fileInfo" class="hidden mt-4 p-4 bg-blue-50 rounded-lg">
139
+ <div class="flex items-center">
140
+ <i class="fas fa-file-pdf text-red-500 text-2xl mr-3"></i>
141
+ <div class="flex-1">
142
+ <div class="flex justify-between items-center">
143
+ <span id="fileName" class="font-medium text-gray-800">sample.pdf</span>
144
+ <span id="fileSize" class="text-sm text-gray-500">2.4 MB</span>
145
+ </div>
146
+ <div class="w-full bg-gray-200 rounded-full h-2.5 mt-2">
147
+ <div id="uploadProgress" class="progress-bar bg-blue-600 h-2.5 rounded-full" style="width: 0%"></div>
148
+ </div>
149
+ </div>
150
+ <button id="cancelUpload" class="ml-4 text-gray-500 hover:text-gray-700">
151
+ <i class="fas fa-times"></i>
152
+ </button>
153
+ </div>
154
+ </div>
155
+ </div>
156
+
157
+ <!-- Processing Options -->
158
+ <div id="processingOptions" class="hidden bg-white rounded-xl shadow-md p-6 mb-8">
159
+ <h2 class="text-xl font-semibold text-gray-800 mb-4">Processing Options</h2>
160
+
161
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
162
+ <!-- OCR Options -->
163
+ <div class="bg-gray-50 p-4 rounded-lg">
164
+ <div class="flex items-center mb-3">
165
+ <i class="fas fa-font text-blue-500 mr-2"></i>
166
+ <h3 class="font-medium text-gray-700">OCR Settings</h3>
167
+ </div>
168
+ <div class="space-y-3">
169
+ <div class="flex items-center">
170
+ <input id="autoOcr" type="checkbox" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded" checked>
171
+ <label for="autoOcr" class="ml-2 block text-sm text-gray-700">Auto-detect and apply OCR if needed</label>
172
+ </div>
173
+ <div class="ml-6 space-y-2">
174
+ <div class="flex items-center">
175
+ <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>
176
+ <label for="ocrEnglish" class="ml-2 block text-sm text-gray-700">English</label>
177
+ </div>
178
+ <div class="flex items-center">
179
+ <input id="ocrSpanish" type="radio" name="ocrLanguage" value="spa" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300">
180
+ <label for="ocrSpanish" class="ml-2 block text-sm text-gray-700">Spanish</label>
181
+ </div>
182
+ <div class="flex items-center">
183
+ <input id="ocrFrench" type="radio" name="ocrLanguage" value="fra" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300">
184
+ <label for="ocrFrench" class="ml-2 block text-sm text-gray-700">French</label>
185
+ </div>
186
+ </div>
187
+ <div class="flex items-center mt-2">
188
+ <input id="enhanceOcr" type="checkbox" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded" checked>
189
+ <label for="enhanceOcr" class="ml-2 block text-sm text-gray-700">Enhance image quality before OCR</label>
190
+ </div>
191
+ </div>
192
+ </div>
193
+
194
+ <!-- Conversion Options -->
195
+ <div class="bg-gray-50 p-4 rounded-lg">
196
+ <div class="flex items-center mb-3">
197
+ <i class="fas fa-exchange-alt text-blue-500 mr-2"></i>
198
+ <h3 class="font-medium text-gray-700">Conversion Options</h3>
199
+ </div>
200
+ <div class="space-y-3">
201
+ <label class="block text-sm font-medium text-gray-700">Output Format</label>
202
+ <div class="grid grid-cols-3 gap-2">
203
+ <button data-format="docx" class="format-option bg-white border border-gray-200 rounded-lg p-3 text-center hover:border-blue-300 transition">
204
+ <i class="fas fa-file-word text-blue-500 text-2xl mb-1"></i>
205
+ <span class="block text-xs font-medium">DOCX</span>
206
+ </button>
207
+ <button data-format="txt" class="format-option bg-white border border-gray-200 rounded-lg p-3 text-center hover:border-blue-300 transition">
208
+ <i class="fas fa-file-alt text-gray-500 text-2xl mb-1"></i>
209
+ <span class="block text-xs font-medium">TXT</span>
210
+ </button>
211
+ <button data-format="html" class="format-option bg-white border border-gray-200 rounded-lg p-3 text-center hover:border-blue-300 transition">
212
+ <i class="fas fa-code text-orange-500 text-2xl mb-1"></i>
213
+ <span class="block text-xs font-medium">HTML</span>
214
+ </button>
215
+ <button data-format="epub" class="format-option bg-white border border-gray-200 rounded-lg p-3 text-center hover:border-blue-300 transition">
216
+ <i class="fas fa-book text-purple-500 text-2xl mb-1"></i>
217
+ <span class="block text-xs font-medium">EPUB</span>
218
+ </button>
219
+ <button data-format="odt" class="format-option bg-white border border-gray-200 rounded-lg p-3 text-center hover:border-blue-300 transition">
220
+ <i class="fas fa-file-alt text-blue-400 text-2xl mb-1"></i>
221
+ <span class="block text-xs font-medium">ODT</span>
222
+ </button>
223
+ <button data-format="markdown" class="format-option bg-white border border-gray-200 rounded-lg p-3 text-center hover:border-blue-300 transition">
224
+ <i class="fas fa-file-code text-gray-700 text-2xl mb-1"></i>
225
+ <span class="block text-xs font-medium">Markdown</span>
226
+ </button>
227
+ </div>
228
+ </div>
229
+ </div>
230
+ </div>
231
+
232
+ <div class="mt-6 flex justify-end">
233
+ <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">
234
+ <i class="fas fa-cog mr-2"></i> Process File
235
+ </button>
236
+ </div>
237
+ </div>
238
+
239
+ <!-- Results Section -->
240
+ <div id="resultsSection" class="hidden bg-white rounded-xl shadow-md p-6">
241
+ <div class="flex justify-between items-center mb-4">
242
+ <h2 class="text-xl font-semibold text-gray-800">Results</h2>
243
+ <div class="flex space-x-2">
244
+ <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">
245
+ <i class="fas fa-download mr-2"></i> Download
246
+ </button>
247
+ <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">
248
+ <i class="fas fa-plus mr-2"></i> New File
249
+ </button>
250
+ </div>
251
+ </div>
252
+
253
+ <div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
254
+ <!-- Original PDF Viewer -->
255
+ <div class="lg:col-span-1">
256
+ <div class="bg-gray-100 rounded-lg p-3 mb-2">
257
+ <h3 class="font-medium text-gray-700 flex items-center">
258
+ <i class="fas fa-file-pdf text-red-500 mr-2"></i> Original PDF
259
+ </h3>
260
+ </div>
261
+ <div class="pdf-viewer bg-gray-50 rounded-lg overflow-hidden">
262
+ <div class="h-full flex items-center justify-center text-gray-400">
263
+ <div class="text-center">
264
+ <i class="fas fa-file-pdf text-5xl mb-2"></i>
265
+ <p>PDF Preview</p>
266
+ </div>
267
+ </div>
268
+ </div>
269
+ </div>
270
+
271
+ <!-- Extracted Text -->
272
+ <div class="lg:col-span-2">
273
+ <div class="bg-gray-100 rounded-lg p-3 mb-2">
274
+ <h3 class="font-medium text-gray-700 flex items-center">
275
+ <i class="fas fa-font text-blue-500 mr-2"></i> Extracted Text
276
+ </h3>
277
+ </div>
278
+ <div class="pdf-viewer bg-white border border-gray-200 rounded-lg p-4 overflow-y-auto">
279
+ <div id="extractedText" class="prose max-w-none">
280
+ <p class="text-gray-500 italic">Text will appear here after processing...</p>
281
+ </div>
282
+ </div>
283
+ </div>
284
+ </div>
285
+
286
+ <!-- Conversion Status -->
287
+ <div id="conversionStatus" class="mt-6 hidden">
288
+ <div class="bg-blue-50 border-l-4 border-blue-500 p-4">
289
+ <div class="flex">
290
+ <div class="flex-shrink-0">
291
+ <i class="fas fa-cog fa-spin text-blue-500"></i>
292
+ </div>
293
+ <div class="ml-3">
294
+ <h3 class="text-sm font-medium text-blue-800">Processing your file</h3>
295
+ <div class="mt-2 text-sm text-blue-700">
296
+ <p id="statusMessage">Performing OCR and converting to DOCX...</p>
297
+ <div class="w-full bg-gray-200 rounded-full h-2.5 mt-2">
298
+ <div id="processProgress" class="progress-bar bg-blue-600 h-2.5 rounded-full" style="width: 0%"></div>
299
+ </div>
300
+ </div>
301
+ </div>
302
+ </div>
303
+ </div>
304
+ </div>
305
+ </div>
306
+
307
+ <!-- Features Section -->
308
+ <div class="mt-12">
309
+ <h2 class="text-2xl font-bold text-gray-800 mb-6 text-center">Why Choose PDF Magic?</h2>
310
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
311
+ <div class="bg-white p-6 rounded-xl shadow-sm hover:shadow-md transition">
312
+ <div class="text-blue-500 mb-4">
313
+ <i class="fas fa-robot text-3xl"></i>
314
+ </div>
315
+ <h3 class="text-lg font-semibold mb-2">Smart OCR</h3>
316
+ <p class="text-gray-600">Automatically detects scanned documents and applies high-quality OCR to extract text with precision.</p>
317
+ </div>
318
+ <div class="bg-white p-6 rounded-xl shadow-sm hover:shadow-md transition">
319
+ <div class="text-green-500 mb-4">
320
+ <i class="fas fa-exchange-alt text-3xl"></i>
321
+ </div>
322
+ <h3 class="text-lg font-semibold mb-2">Multi-format Conversion</h3>
323
+ <p class="text-gray-600">Convert your PDFs to DOCX, TXT, HTML, EPUB and more using powerful Pandoc engine.</p>
324
+ </div>
325
+ <div class="bg-white p-6 rounded-xl shadow-sm hover:shadow-md transition">
326
+ <div class="text-purple-500 mb-4">
327
+ <i class="fas fa-lock text-3xl"></i>
328
+ </div>
329
+ <h3 class="text-lg font-semibold mb-2">Secure Processing</h3>
330
+ <p class="text-gray-600">Your files are processed securely in your browser and never uploaded to our servers.</p>
331
+ </div>
332
+ </div>
333
+ </div>
334
+ </div>
335
+ </div>
336
+
337
+ <script>
338
+ // Mobile menu toggle
339
+ document.getElementById('menuToggle').addEventListener('click', function() {
340
+ document.getElementById('sidebar').classList.toggle('open');
341
+ });
342
+
343
+ // File upload handling
344
+ const dropzone = document.getElementById('dropzone');
345
+ const fileInput = document.getElementById('fileInput');
346
+ const browseBtn = document.getElementById('browseBtn');
347
+ const fileInfo = document.getElementById('fileInfo');
348
+ const fileName = document.getElementById('fileName');
349
+ const fileSize = document.getElementById('fileSize');
350
+ const uploadProgress = document.getElementById('uploadProgress');
351
+ const cancelUpload = document.getElementById('cancelUpload');
352
+ const processingOptions = document.getElementById('processingOptions');
353
+ const resultsSection = document.getElementById('resultsSection');
354
+ const processBtn = document.getElementById('processBtn');
355
+ const downloadBtn = document.getElementById('downloadBtn');
356
+ const newFileBtn = document.getElementById('newFileBtn');
357
+ const conversionStatus = document.getElementById('conversionStatus');
358
+ const statusMessage = document.getElementById('statusMessage');
359
+ const processProgress = document.getElementById('processProgress');
360
+ const extractedText = document.getElementById('extractedText');
361
+ const formatOptions = document.querySelectorAll('.format-option');
362
+
363
+ let selectedFormat = 'docx';
364
+ let currentFile = null;
365
+
366
+ // Highlight dropzone when dragging over
367
+ ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
368
+ dropzone.addEventListener(eventName, preventDefaults, false);
369
+ });
370
+
371
+ function preventDefaults(e) {
372
+ e.preventDefault();
373
+ e.stopPropagation();
374
+ }
375
+
376
+ ['dragenter', 'dragover'].forEach(eventName => {
377
+ dropzone.addEventListener(eventName, highlight, false);
378
+ });
379
+
380
+ ['dragleave', 'drop'].forEach(eventName => {
381
+ dropzone.addEventListener(eventName, unhighlight, false);
382
+ });
383
+
384
+ function highlight() {
385
+ dropzone.classList.add('active');
386
+ }
387
+
388
+ function unhighlight() {
389
+ dropzone.classList.remove('active');
390
+ }
391
+
392
+ // Handle dropped files
393
+ dropzone.addEventListener('drop', handleDrop, false);
394
+
395
+ function handleDrop(e) {
396
+ const dt = e.dataTransfer;
397
+ const files = dt.files;
398
+ handleFiles(files);
399
+ }
400
+
401
+ // Handle file selection via button
402
+ browseBtn.addEventListener('click', () => {
403
+ fileInput.click();
404
+ });
405
+
406
+ fileInput.addEventListener('change', () => {
407
+ if (fileInput.files.length) {
408
+ handleFiles(fileInput.files);
409
+ }
410
+ });
411
+
412
+ // Cancel upload
413
+ cancelUpload.addEventListener('click', () => {
414
+ resetUpload();
415
+ });
416
+
417
+ // New file button
418
+ newFileBtn.addEventListener('click', resetUpload);
419
+
420
+ // Format selection
421
+ formatOptions.forEach(option => {
422
+ option.addEventListener('click', function() {
423
+ formatOptions.forEach(opt => opt.classList.remove('border-blue-500', 'bg-blue-50'));
424
+ this.classList.add('border-blue-500', 'bg-blue-50');
425
+ selectedFormat = this.dataset.format;
426
+ });
427
+ });
428
+
429
+ // Process file button
430
+ processBtn.addEventListener('click', processFile);
431
+
432
+ // Download button
433
+ downloadBtn.addEventListener('click', () => {
434
+ alert(`Downloading file in ${selectedFormat.toUpperCase()} format`);
435
+ // In a real app, this would trigger the download of the converted file
436
+ });
437
+
438
+ function handleFiles(files) {
439
+ currentFile = files[0];
440
+
441
+ // Update file info
442
+ fileName.textContent = currentFile.name;
443
+ fileSize.textContent = formatFileSize(currentFile.size);
444
+
445
+ // Show file info and hide dropzone
446
+ fileInfo.classList.remove('hidden');
447
+ dropzone.classList.add('hidden');
448
+
449
+ // Simulate upload progress
450
+ let progress = 0;
451
+ const interval = setInterval(() => {
452
+ progress += Math.random() * 10;
453
+ if (progress >= 100) {
454
+ progress = 100;
455
+ clearInterval(interval);
456
+ uploadComplete();
457
+ }
458
+ uploadProgress.style.width = `${progress}%`;
459
+ }, 200);
460
+ }
461
+
462
+ function uploadComplete() {
463
+ processingOptions.classList.remove('hidden');
464
+ }
465
+
466
+ function processFile() {
467
+ processingOptions.classList.add('hidden');
468
+ conversionStatus.classList.remove('hidden');
469
+ resultsSection.classList.remove('hidden');
470
+
471
+ // Simulate processing steps
472
+ let progress = 0;
473
+ const steps = [
474
+ {progress: 20, message: "Analyzing PDF content..."},
475
+ {progress: 40, message: "Detecting text layers..."},
476
+ {progress: 60, message: "Applying OCR to scanned pages..."},
477
+ {progress: 80, message: `Converting to ${selectedFormat.toUpperCase()} format...`},
478
+ {progress: 100, message: "Conversion complete!"}
479
+ ];
480
+
481
+ let currentStep = 0;
482
+ const processInterval = setInterval(() => {
483
+ if (currentStep < steps.length) {
484
+ progress = steps[currentStep].progress;
485
+ statusMessage.textContent = steps[currentStep].message;
486
+ processProgress.style.width = `${progress}%`;
487
+ currentStep++;
488
+
489
+ // Update extracted text at certain steps
490
+ if (currentStep === 3) {
491
+ extractedText.innerHTML = `
492
+ <h1>Sample Extracted Document</h1>
493
+ <p>This is text that was extracted from your PDF document using our advanced OCR technology.</p>
494
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam in dui mauris. Vivamus hendrerit arcu sed erat molestie vehicula.</p>
495
+ <h2>Section 1</h2>
496
+ <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>
497
+ <p>This text would normally be extracted from your actual PDF file.</p>
498
+ `;
499
+ }
500
+ } else {
501
+ clearInterval(processInterval);
502
+ conversionStatus.classList.add('hidden');
503
+ }
504
+ }, 1500);
505
+ }
506
+
507
+ function resetUpload() {
508
+ fileInfo.classList.add('hidden');
509
+ processingOptions.classList.add('hidden');
510
+ resultsSection.classList.add('hidden');
511
+ conversionStatus.classList.add('hidden');
512
+ dropzone.classList.remove('hidden');
513
+ uploadProgress.style.width = '0%';
514
+ processProgress.style.width = '0%';
515
+ fileInput.value = '';
516
+ currentFile = null;
517
+ extractedText.innerHTML = '<p class="text-gray-500 italic">Text will appear here after processing...</p>';
518
+ }
519
+
520
+ function formatFileSize(bytes) {
521
+ if (bytes === 0) return '0 Bytes';
522
+ const k = 1024;
523
+ const sizes = ['Bytes', 'KB', 'MB', 'GB'];
524
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
525
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
526
+ }
527
+ </script>
528
+ <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>
529
+ </html>