KeenConverters

WEBP to DOCX Converter

Convert your WEBP images to DOCX documents with OCR text extraction

Drop WEBP files here or click to browse

Support for multiple WEBP files • Max size: 10MB per file

Professional WEBP to DOCX conversion tool • Supports OCR text extraction and image embedding

`;return new Blob([docContent], { type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' }); }createDocxWithImage(base64Data, fileName) { // Create HTML content with embedded image const docContent = `

Image Document: ${fileName}

${fileName}

Original file: ${fileName}

Generated by WEBP to DOCX Converter

`;return new Blob([docContent], { type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' }); }fileToBase64(file) { return new Promise((resolve, reject) => { const reader = new FileReader(); reader.onload = () => { const base64 = reader.result.split(',')[1]; resolve(base64); }; reader.onerror = reject; reader.readAsDataURL(file); }); }showProgress() { this.actionsSection.style.display = 'none'; this.progressSection.style.display = 'block'; this.resultsSection.style.display = 'none'; }updateProgress() { const progress = ((this.currentConversionIndex + 1) / this.files.length) * 100; this.progressFill.style.width = `${progress}%`; this.progressText.textContent = `${Math.round(progress)}%`; }showResults() { this.progressSection.style.display = 'none'; this.resultsSection.style.display = 'block'; this.renderResults(); }renderResults() { this.resultsList.innerHTML = this.convertedFiles.map((file, index) => `

${file.docxName}

Converted from ${file.originalName} • ${this.formatFileSize(file.blob.size)}

`).join(''); }downloadFile(index) { const file = this.convertedFiles[index]; const url = URL.createObjectURL(file.blob); const a = document.createElement('a'); a.href = url; a.download = file.docxName; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); }async downloadAllFiles() { if (this.convertedFiles.length === 0) return;try { const zip = new JSZip(); this.convertedFiles.forEach(file => { zip.file(file.docxName, file.blob); });const zipBlob = await zip.generateAsync({ type: 'blob' }); const url = URL.createObjectURL(zipBlob); const a = document.createElement('a'); a.href = url; a.download = 'converted_documents.zip'; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url);} catch (error) { this.showError(`Failed to create ZIP file: ${error.message}`); } }showError(message) { this.errorMessage.textContent = message; this.errorSection.style.display = 'block'; this.errorSection.classList.add('fade-in'); // Auto-hide error after 5 seconds setTimeout(() => { this.hideError(); }, 5000); }hideError() { this.errorSection.style.display = 'none'; this.errorSection.classList.remove('fade-in'); }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]; } }// Initialize the converter when the page loads let converter; document.addEventListener('DOMContentLoaded', () => { converter = new WebpToDocxConverter(); });// Handle global errors window.addEventListener('error', (event) => { console.error('Global error:', event.error); if (converter) { converter.showError('An unexpected error occurred. Please try again.'); } });// Handle unhandled promise rejections window.addEventListener('unhandledrejection', (event) => { console.error('Unhandled promise rejection:', event.reason); if (converter) { converter.showError('An error occurred during processing. Please try again.'); } });