File size: 17,915 Bytes
50abe68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>PDF to DOC Converter</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;
        }
        #preview {
            max-height: 300px;
            overflow-y: auto;
        }
    </style>
</head>
<body class="bg-gray-50 min-h-screen">
    <div class="container mx-auto px-4 py-8">
        <div class="max-w-3xl mx-auto bg-white rounded-xl shadow-md overflow-hidden">
            <!-- Header -->
            <div class="bg-gradient-to-r from-blue-500 to-indigo-600 p-6 text-white">
                <div class="flex items-center justify-between">
                    <div>
                        <h1 class="text-2xl font-bold">Document Converter</h1>
                        <div class="flex space-x-4 mt-2">
                            <button id="pdf-to-doc-tab" class="tab-button active px-4 py-1 rounded-full bg-white text-blue-600 font-medium">
                                PDF to DOC
                            </button>
                            <button id="doc-to-pdf-tab" class="tab-button px-4 py-1 rounded-full bg-white/20 hover:bg-white/30 text-white font-medium">
                                DOC to PDF
                            </button>
                        </div>
                    </div>
                    <div class="bg-white/20 p-3 rounded-full">
                        <i class="fas fa-file-word text-2xl"></i>
                    </div>
                </div>
            </div>

            <!-- Main Content -->
            <div class="p-6">
                <!-- PDF to DOC Content (default visible) -->
                <div id="pdf-to-doc-content">
                <!-- Upload Area -->
                <div id="upload-section" class="mb-8">
                    <div class="dropzone rounded-lg p-8 text-center cursor-pointer mb-4" id="dropzone">
                        <div class="flex flex-col items-center justify-center space-y-4">
                            <div class="bg-blue-100 p-4 rounded-full">
                                <i class="fas fa-file-pdf text-blue-600 text-3xl"></i>
                            </div>
                            <h3 class="text-lg font-medium text-gray-700">Drag & drop your PDF file here</h3>
                            <p class="text-gray-500">or</p>
                            <label for="file-input" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-md cursor-pointer transition">
                                <i class="fas fa-upload mr-2"></i> Select File
                            </label>
                            <input type="file" id="file-input" class="hidden" accept=".pdf">
                        </div>
                    </div>
                    <p class="text-sm text-gray-500 text-center">Supported formats: PDF (Max 10MB)</p>
                </div>

                <!-- File Info -->
                <div id="file-info" class="hidden mb-6 bg-gray-50 p-4 rounded-lg border border-gray-200">
                    <div class="flex items-center justify-between">
                        <div class="flex items-center space-x-3">
                            <i class="fas fa-file-pdf text-red-500 text-2xl"></i>
                            <div>
                                <h4 id="file-name" class="font-medium text-gray-800"></h4>
                                <p id="file-size" class="text-sm text-gray-500"></p>
                            </div>
                        </div>
                        <button id="remove-file" class="text-gray-400 hover:text-gray-600">
                            <i class="fas fa-times"></i>
                        </button>
                    </div>
                </div>

                <!-- Preview (simulated) -->
                <div id="preview-section" class="hidden mb-6">
                    <h3 class="text-lg font-medium text-gray-700 mb-3">Preview</h3>
                    <div id="preview" class="bg-gray-100 p-4 rounded-lg border border-gray-300">
                        <p class="text-gray-500 italic">PDF preview would appear here in a real implementation</p>
                    </div>
                </div>

                <!-- Options -->
                <div class="mb-6">
                    <h3 class="text-lg font-medium text-gray-700 mb-3">Conversion Options</h3>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                        <div class="flex items-center space-x-2">
                            <input type="checkbox" id="preserve-layout" class="rounded text-blue-600" checked>
                            <label for="preserve-layout" class="text-gray-700">Preserve original layout</label>
                        </div>
                        <div class="flex items-center space-x-2">
                            <input type="checkbox" id="include-images" class="rounded text-blue-600" checked>
                            <label for="include-images" class="text-gray-700">Include images</label>
                        </div>
                    </div>
                </div>

                <!-- Progress Bar -->
                <div id="progress-section" class="hidden mb-6">
                    <div class="flex justify-between mb-1">
                        <span class="text-sm font-medium text-gray-700">Converting...</span>
                        <span id="progress-percentage" class="text-sm font-medium text-gray-700">0%</span>
                    </div>
                    <div class="w-full bg-gray-200 rounded-full h-2.5">
                        <div id="progress-bar" class="progress-bar bg-blue-600 h-2.5 rounded-full" style="width: 0%"></div>
                    </div>
                </div>

                <!-- Convert Button -->
                <div class="text-center">
                    <button id="convert-btn" class="bg-green-600 hover:bg-green-700 text-white px-8 py-3 rounded-md font-medium transition transform hover:scale-105 disabled:opacity-50 disabled:cursor-not-allowed disabled:transform-none" disabled>
                        <i class="fas fa-exchange-alt mr-2"></i> Convert to DOC
                    </button>
                </div>

                <!-- Download Section -->
                <div id="download-section" class="hidden mt-8 bg-green-50 border border-green-200 rounded-lg p-4">
                    <div class="flex flex-col md:flex-row items-center justify-between">
                        <div class="flex items-center space-x-3 mb-4 md:mb-0">
                            <div class="bg-green-100 p-3 rounded-full">
                                <i class="fas fa-file-word text-green-600 text-xl"></i>
                            </div>
                            <div>
                                <h4 id="output-file-name" class="font-medium text-gray-800"></h4>
                                <p class="text-sm text-gray-500">Conversion successful!</p>
                            </div>
                        </div>
                        <button id="download-btn" class="bg-green-600 hover:bg-green-700 text-white px-6 py-2 rounded-md font-medium transition">
                            <i class="fas fa-download mr-2"></i> Download DOC
                        </button>
                    </div>
                </div>
            </div>

            <!-- Footer -->
            <div class="bg-gray-100 px-6 py-4 text-center">
                <p class="text-sm text-gray-600">Convert your PDFs to editable Word documents in seconds</p>
            </div>
        </div>

        <!-- Info Box -->
        <div class="max-w-3xl mx-auto mt-6 bg-blue-50 border border-blue-200 rounded-lg p-4">
            <div class="flex items-start space-x-3">
                <div class="text-blue-500 mt-1">
                    <i class="fas fa-info-circle"></i>
                </div>
                <div>
                    <h3 class="font-medium text-blue-800">How it works</h3>
                    <p class="text-sm text-blue-600 mt-1">
                        This is a frontend demo. In a real implementation, you would need a backend service or API (like PDFTron, Adobe PDF Services, or other conversion libraries) to handle the actual PDF to DOC conversion.
                    </p>
                </div>
            </div>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // Tab switching functionality
            const pdfToDocTab = document.getElementById('pdf-to-doc-tab');
            const docToPdfTab = document.getElementById('doc-to-pdf-tab');
            const pdfToDocContent = document.getElementById('pdf-to-doc-content');
            const docToPdfContent = document.getElementById('doc-to-pdf-content');

            pdfToDocTab.addEventListener('click', () => {
                pdfToDocTab.classList.remove('bg-white/20', 'text-white', 'hover:bg-white/30');
                pdfToDocTab.classList.add('bg-white', 'text-blue-600');
                docToPdfTab.classList.remove('bg-white', 'text-blue-600');
                docToPdfTab.classList.add('bg-white/20', 'text-white', 'hover:bg-white/30');
                pdfToDocContent.classList.remove('hidden');
                docToPdfContent.classList.add('hidden');
            });

            docToPdfTab.addEventListener('click', () => {
                docToPdfTab.classList.remove('bg-white/20', 'text-white', 'hover:bg-white/30');
                docToPdfTab.classList.add('bg-white', 'text-blue-600');
                pdfToDocTab.classList.remove('bg-white', 'text-blue-600');
                pdfToDocTab.classList.add('bg-white/20', 'text-white', 'hover:bg-white/30');
                docToPdfContent.classList.remove('hidden');
                pdfToDocContent.classList.add('hidden');
            });

            const dropzone = document.getElementById('dropzone');
            const fileInput = document.getElementById('file-input');
            const fileInfo = document.getElementById('file-info');
            const fileName = document.getElementById('file-name');
            const fileSize = document.getElementById('file-size');
            const removeFileBtn = document.getElementById('remove-file');
            const convertBtn = document.getElementById('convert-btn');
            const previewSection = document.getElementById('preview-section');
            const progressSection = document.getElementById('progress-section');
            const progressBar = document.getElementById('progress-bar');
            const progressPercentage = document.getElementById('progress-percentage');
            const downloadSection = document.getElementById('download-section');
            const outputFileName = document.getElementById('output-file-name');
            const downloadBtn = document.getElementById('download-btn');

            let selectedFile = null;

            // Drag and drop events
            ['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');
            }

            dropzone.addEventListener('drop', handleDrop, false);

            function handleDrop(e) {
                const dt = e.dataTransfer;
                const file = dt.files[0];
                handleFile(file);
            }

            // File input change
            fileInput.addEventListener('change', function() {
                if (this.files.length) {
                    handleFile(this.files[0]);
                }
            });

            // Handle the selected file
            function handleFile(file) {
                if (!file.type.includes('pdf')) {
                    alert('Please select a PDF file.');
                    return;
                }

                if (file.size > 10 * 1024 * 1024) { // 10MB limit
                    alert('File size exceeds 10MB limit.');
                    return;
                }

                selectedFile = file;
                fileName.textContent = file.name;
                fileSize.textContent = formatFileSize(file.size);
                fileInfo.classList.remove('hidden');
                convertBtn.disabled = false;
                previewSection.classList.remove('hidden');

                // Simulate preview (in a real app, you'd use a PDF viewer library)
                const preview = document.getElementById('preview');
                preview.innerHTML = `
                    <div class="text-center py-8">
                        <i class="fas fa-file-pdf text-4xl text-red-500 mb-3"></i>
                        <p class="font-medium">${file.name}</p>
                        <p class="text-sm text-gray-500 mt-1">${formatFileSize(file.size)}</p>
                        <p class="text-gray-500 italic mt-4">In a real implementation, this would show a preview of the PDF content.</p>
                    </div>
                `;
            }

            // Remove file
            removeFileBtn.addEventListener('click', function() {
                selectedFile = null;
                fileInput.value = '';
                fileInfo.classList.add('hidden');
                convertBtn.disabled = true;
                previewSection.classList.add('hidden');
                progressSection.classList.add('hidden');
                downloadSection.classList.add('hidden');
            });

            // Convert button click
            convertBtn.addEventListener('click', function() {
                if (!selectedFile) return;

                // Show progress
                progressSection.classList.remove('hidden');
                convertBtn.disabled = true;

                // Simulate conversion progress
                let progress = 0;
                const interval = setInterval(() => {
                    progress += Math.random() * 10;
                    if (progress > 100) progress = 100;
                    
                    progressBar.style.width = `${progress}%`;
                    progressPercentage.textContent = `${Math.round(progress)}%`;
                    
                    if (progress === 100) {
                        clearInterval(interval);
                        setTimeout(showDownloadSection, 500);
                    }
                }, 200);
            });

            function showDownloadSection() {
                progressSection.classList.add('hidden');
                downloadSection.classList.remove('hidden');
                
                // Set output filename
                const originalName = selectedFile.name;
                const docName = originalName.endsWith('.pdf') ? 
                    originalName.replace('.pdf', '.doc') : 
                    originalName + '.doc';
                
                outputFileName.textContent = docName;
            }

            // Download button click
            downloadBtn.addEventListener('click', function() {
                alert('In a real implementation, this would download the converted DOC file.');
                // In a real app, you would:
                // 1. Get the converted file from your backend
                // 2. Create a download link like this:
                // const url = URL.createObjectURL(convertedFile);
                // const a = document.createElement('a');
                // a.href = url;
                // a.download = outputFileName.textContent;
                // document.body.appendChild(a);
                // a.click();
                // document.body.removeChild(a);
                // URL.revokeObjectURL(url);
            });

            // Helper function to format file size
            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=dpp002/docpix" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>